[Rails] "Remembering" link to redirect to after logging in
Xavier Noria
fxn at hashref.com
Tue Mar 21 11:02:03 GMT 2006
On Mar 21, 2006, at 11:36, Woei Shyang wrote:
> Suppose I have a resource such as http://localhost:3000/topsecret/data
> that requires the user to login first.
>
> What I did was make use of before_filter to check and see if the
> session
> variable is set with the logged in user's id (similar to the
> example in
> "Agile Web Development with Rails").
>
> However while the filtering function does work correctly in
> redirecting
> the user to the login page, how do I actually capture the original
> request made by the user so that I can redirect the user back to the
> required resource after s/he has logged in?
acts_as_authenticated[*] does this out of the box. However, if you
want to write your own system take a look at the method
redirect_back_or_default here
http://tinyurl.com/m62y5
-- fxn
[*] http://wiki.rubyonrails.org/rails/pages/Acts_as_authenticated
More information about the Rails
mailing list