I think I got this out of heirarki, you should look in the "open source
projects" link at rubyonrails.org community section for other useful
examples.
@session[:return_to] = @request.request_uri # cross-controller
compatible
redirect_to_url @session[:return_to]
-Jeff
----- Original Message -----
From: "Peter-Frank Spierenburg"
<peter-QwGnaCI3XxIdnm+yROfE0A@public.gmane.org>
To: <Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org>
Sent: Wednesday, March 30, 2005 10:53 AM
Subject: [Rails] Redirecting to the previous view
> Greetings,
>
> I''m trying to implement a simple authentication system. The
''login'' action
> of the ''users'' controller looks like this:
>
> def login
> @session["user"] =
User.authenticate(@params["username"],
> @params["password"])
> if current_user.guest?
> @session["login_message"]="Invalid Login"
> end
> redirect_to(:action => "index")
> end
>
> The ''redirect_to'' call naturally redirects to the
''index'' action of the
> ''users'' controller, but I would like for it to redirect
to the previous
> view, whatever view that happens to be. What would be the best mechanism
> for achieving this?
>
> Peter.
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails