When you try to access a page in Devise that needs authentication, Devise saves this path and redirects you to the sign in page. After you sign in, Devise will redirect you back to that page.
If no page was saved, it will redirect you to what after_sign_in_path_for says (usually root_path).
If you want to save the page the user is navigating on, even if this page is not required access, you can put sth like this in your app controller:
def store_location
if request.get? && request.format.html? && !request.xhr? && !devise_controller?
session[:"scope.return_to"] = request.request_uri
end
end
where "scope" in the session key, is your own scope (user for instance = user.return_to).
This key is for Rails 2.x only, if you're using Devise with Rails 3, use "scope_return_to" (underline instead of dot).
If that works for you, I'd ask you to create a page on the wiki, explaining this.
Thanks.
--
At.
Carlos A. da Silva