Back to Devise Wiki

How To: Redirect To A Specific Page On Successful Sign In Sign Out

How-to:-redirect-to-a-specific-page-on-successful-sign-in-sign-out.md

latest709 B
Original Source

You can override the default behaviour by creating an after_sign_in_path_for [RDoc] method in your ApplicationController and have it return the path for the page you want:

ruby
def after_sign_in_path_for(resource)
 current_user_path
end

There exists a similar method for sign out: after_sign_out_path_for [RDoc]

Keeping user on the same page after signing out:

Default value is root_path.

ruby
def after_sign_out_path_for(resource_or_scope)
 request.referrer
end