Re: [Rails] Redirecting without Plugins
On Sat, Feb 16, 2013 at 8:52 AM, Ryo Saeba <lists@ruby-forum.com> wrote:
> I want to be redirected to the current page, after having logged in. I
> searched google and only saw ways to do this using certain plugins like
> devise.
>
> Isn't there a simple Way to implement this path?
>
> I start out with
>
> def store_location
> session[:return_to] = request.fullpath
> end
>
> and I think the only thing left is passing this path to my redirect_ to
> code Line in the Sessions Controller, but "redirect_to store_location"
> won't work.
This isn't doing what you think. You may want to set up something more
akin to accessors:
def store_location=(location)
session[:return_to] = location
end
def store_location
session[:return_to]
end
Then call the first method when you want to save the return page, and
the second when you want to retrieve it.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home