Last Updated: February 25, 2016
·
2.022K
· pbruna

Redirect after sign_up (no sign_in) with Devise

So today im back cooking a new Rails app and one of the requirements was to redirect to an special page after the user create an account.

Like the title says im using Devise and this tip works if you are using the trackable module. So in application_controller.rb:

def after_sign_in_path_for(resource)
  if resource.sign_in_count == 1
    user_path(resource)
  else
    stored_location_for(resource) || users_path
  end
end

We are using the numbers of times the users has logged to the system, resource.signincount, and if this number is 1 it has to be the first time, or in my case, after the user sign_up