I have a root_path
on my Rails application that is not user-protected i.e. it\'s a simple portal homepage, with a login form.
After the users log in, I\
The login form is on every pages (top/sidebar) or you have a login page?
If is on every pages, you can use request.referrer
to know where the user came from.
You can override the after_sign_in_path_for method without losing the desired behavior.
def after_sign_in_path_for(resource_or_scope)
stored_location_for(resource_or_scope) || dashboard_path
end
I would also put a condition in the root_path action that redirects if current_user exists.
RootController.rb
def index
if current_user
redirect_to dashboard_path
else
super #or whatever
end
end
You could also use a before_filter, if you wanted to add the redirect to many unprotected actions.