How To: Redirect to a specific page on successful sign in and sign out

Gary edited this page Sep 27, 2018 · 3 revisions

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:

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

def after_sign_out_path_for(resource_or_scope)
  request.referrer
end

Note:

Some versions of Devise may have issues with properly redirecting after signing in (See Issue 4742). Upgrade to the latest version while troubleshooting to help with isolating the issue.

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.