I have overwritten after_sign_in_path_for in my application controller as follows:
application_controller.rb
def after_sign_in_path_for resource
case resource
when User
blah
when Admin
blah
end
end
This works when the user signs in via the sign in page. But after_sign_in_path_for
method doesn't get called at all when a user is signed in via Devise's Token Authenticatable module. The user gets taken to the root_path
. How can I change this?
I'm using Rails 3.2.0, ruby 1.9.3p194 and Devise 2.1.2.
I would advise you to take a look at Devise's own ConfirmationsController , it looks to me like its calling after_sign_in_path_for, and the resource would be user I would assume. But it may take overriding that Controller with your own, so you could log the resource before you'll know for sure.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.