Method: Devise::Controllers::Helpers#after_sign_in_path_for

Defined in:
lib/devise/controllers/helpers.rb

#after_sign_in_path_for(resource_or_scope) ⇒ Object

The default url to be used after signing in. This is used by all Devise controllers and you can overwrite it in your ApplicationController to provide a custom hook for a custom resource.

By default, it first tries to find a resource_root_path, otherwise it uses the root path. For a user scope, you can define the default url in the following way:

map.user_root '/users', :controller => 'users' # creates user_root_path

map.namespace :user do |user|
  user.root :controller => 'users' # creates user_root_path
end

If the resource root path is not defined, root_path is used. However, if this default is not enough, you can customize it, for example:

def (resource)
  if resource.is_a?(User) && resource.can_publish?
    publisher_url
  else
    super
  end
end


115
116
117
118
119
# File 'lib/devise/controllers/helpers.rb', line 115

def (resource_or_scope)
  scope = Devise::Mapping.find_scope!(resource_or_scope)
  home_path = "#{scope}_root_path"
  respond_to?(home_path, true) ? send(home_path) : root_path
end