On 7/25/07, Matthew L. email@example.com wrote:
I have a page where anyone can edit some content on it, but they must be
logged in before doing so. Now, when the person clicks on my “edit”
action, they are automatically redirected to the login form. Then the
person logs in, but when they log in, I would like to have them
redirected to the page where they wanted to edit the content on. How can
I do that?
The basic idea is that before you redirect to the login page, you
stash away request.request_uri somewhere. (The session object is
handy, or you can put it in a hidden field in the login form).
Then, when they’ve successfully authenticated, grab the saved uri and
redirect to there. (You’ll need some kind of default place to go in
case they don’t come to the login page via a redirect.)
I suggest you look at acts_as_authenticated
provides this capability built in. If nothing else, you can look at
his code and see how it’s done.