3
votes

I was having problems redirecting to the last visited page when that page required a sign in Devise Resetting Session On Login and somebody pointed out that you could follow the code example here: https://github.com/plataformatec/devise/wiki/How-To%3A-redirect-to-a-specific-page-on-successful-sign-in

That example calls stored_location_for(resource)...where is that set?

That example works perfectly when used in conjunction with a before_filter :authenticate_user! in my appropriate controllers. Looking at the source code for authenticate_#{resource}!, https://github.com/plataformatec/devise/blob/master/lib/devise/controllers/helpers.rb it doesn't seem to save the location.

Where in the world is the previous location stored?

1

1 Answers

3
votes

The path is stored in session["user_return_to"] (assuming user is your model name).

This appears to be set by store_location! in failure_app.rb

Note that if you only have one devise model, the sign in redirect should work automatically, without you needing to override after_sign_in_path_for in your application_controller.rb.