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'd like it to go to dashboard_path
.
I've done this:
def signed_in_root_path(scope_or_resource)
dashboard_path
end
This apparently should be used when an user signs in, and I don't want it to go to the root_path
, while still keeping the user going back to a previous page if it tries to hit a restricted area and it's either timed out or not logged in.
i.e.:
restricted_page -> login -> restricted_page_but_logged_in
I don't want to change this behavior, and that's why I haven't used after_sign_in_path
, but want to redirect it if it's on root_path
, or any route that doesn't require user authentication.
My problem is that this is not working. After signing in, I'm getting redirected back to root_path
, which I believe is because of after_sign_in_path
getting triggered before.
Is there any way to do this? Thanks!
Edit: This works the second time I log in, i.e. I go to root_path
, log in, gets the flash message stating me that I'm logged in, and enter username and password again on the form on root_path
. I successfully get redirected to dashboard_path
. Still, not quite the behavior I want.