I'm using Devise for user management. I need to run some custom code defining where the user is redirected to after they sign in. I've found the after_sign_in_path_for method, which I think is what I need to use. But I'm not sure how to use it开发者_如何学Python. Where do I put my custom after_sign_in_path_for method to override the default one? Thanks for reading.
this one looks handy, didn't know about it.
sign_in_and_redirect(resource_or_scope, *args)
I cannot get block quote to work so I will just but what the api says below
Sign in an user and tries to redirect first to the stored location and then to the url specified by after_sign_in_path_for. It accepts the same parameters as the sign_in method.
I take this to mean that you pass the path as the second argument and this will override the default root path
for example
sign_in_and_redirect(resource_or_scope, posts_path)
so that would take you to :controller => "post", :action => "index"
精彩评论