I’m looking for a solution that allows a user to:
- Navigate to a page
- Sign up or log in
- Be re-directed to the first page
I have been using Devise for my application be seem to have hit a wall as Device always routes to the root_path after login. I have tried:
def after_sign_in_path_for(resource)
session[:return_to] || root_path
end
But this does not work as the session[:return_to] does not seem to get getting set.
Can anyone shed any light on the best way to do this through Devise – or suggest an alternative Authentication solution that allows this type of action. Thanks
Are you setting the session[:return_to] variable manually? Try adding this to your ApplicationController
Alternatively, you can set your return_to session variable in each controller if you want to have more fine-grained control over which pages actually set the return_to session variable.