Last Updated: February 25, 2016
·
626
· rsludge

Redirect back on sign in with Devise

To do that you should define after_sign_in_path_for in application_controller:

def after_sign_in_path_for(resource)
  sign_in_url = url_for(:action => 'new', :controller => 'sessions', :only_path => false, :protocol => 'http')
  if request.referer == sign_in_url
    super
  else
    stored_location_for(resource) || request.referer || root_path
  end
end