Devise: redefining sessions # new action

I want to be able to send already signed-in-users elsewhere when they go to the login page . Right now they are heading for the root path.

I tried to do my own action in the session controller, but it does not seem to work. The text that I am trying to print in the log for verification does not even appear, so I think the user is redirected somewhere along the chain.

How do you do this?

+3
source share
1 answer

, after_sign_in_path_for. application_controller.rb, , .

def after_sign_in_path_for(resource)
  if current_user.current_sign_in_at > 1.minute.ago
    your_own_path
  else
    super
  end
end
+2

All Articles