class Devise::RegistrationsController

Public Instance Methods

cancel() click to toggle source

GET /resource/cancel Forces the session data which is usually expired after sign in to be expired now. This is useful if the user wants to cancel oauth signing in/up in the middle of the process, removing all OAuth session data.

# File app/controllers/devise/registrations_controller.rb, line 78
def cancel
  expire_data_after_sign_in!
  redirect_to new_registration_path(resource_name)
end
create() { |resource| ... } click to toggle source

POST /resource

# File app/controllers/devise/registrations_controller.rb, line 14
def create
  build_resource(sign_up_params)

  resource.save
  yield resource if block_given?
  if resource.persisted?
    if resource.active_for_authentication?
      set_flash_message :notice, :signed_up if is_flashing_format?
      sign_up(resource_name, resource)
      respond_with resource, location: after_sign_up_path_for(resource)
    else
      set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_flashing_format?
      expire_data_after_sign_in!
      respond_with resource, location: after_inactive_sign_up_path_for(resource)
    end
  else
    clean_up_passwords resource
    set_minimum_password_length
    respond_with resource
  end
end
destroy() { |resource| ... } click to toggle source

DELETE /resource

# File app/controllers/devise/registrations_controller.rb, line 65
def destroy
  resource.destroy
  Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)
  set_flash_message :notice, :destroyed if is_flashing_format?
  yield resource if block_given?
  respond_with_navigational(resource){ redirect_to after_sign_out_path_for(resource_name) }
end
edit() click to toggle source

GET /resource/edit

# File app/controllers/devise/registrations_controller.rb, line 37
def edit
  render :edit
end
new() { |resource| ... } click to toggle source

GET /resource/sign_up

# File app/controllers/devise/registrations_controller.rb, line 6
def new
  build_resource({})
  set_minimum_password_length
  yield resource if block_given?
  respond_with self.resource
end
update() { |resource| ... } click to toggle source

PUT /resource We need to use a copy of the resource because we don't want to change the current user in place.

# File app/controllers/devise/registrations_controller.rb, line 44
def update
  self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key)
  prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)

  resource_updated = update_resource(resource, account_update_params)
  yield resource if block_given?
  if resource_updated
    if is_flashing_format?
      flash_key = update_needs_confirmation?(resource, prev_unconfirmed_email) ?
        :update_needs_confirmation : :updated
      set_flash_message :notice, flash_key
    end
    sign_in resource_name, resource, bypass: true
    respond_with resource, location: after_update_path_for(resource)
  else
    clean_up_passwords resource
    respond_with resource
  end
end

Protected Instance Methods

account_update_params() click to toggle source
# File app/controllers/devise/registrations_controller.rb, line 140
def account_update_params
  devise_parameter_sanitizer.sanitize(:account_update)
end
after_inactive_sign_up_path_for(resource) click to toggle source

The path used after sign up for inactive accounts. You need to overwrite this method in your own RegistrationsController.

# File app/controllers/devise/registrations_controller.rb, line 117
def after_inactive_sign_up_path_for(resource)
  scope = Devise::Mapping.find_scope!(resource)
  router_name = Devise.mappings[scope].router_name
  context = router_name ? send(router_name) : self
  context.respond_to?(:root_path) ? context.root_path : "/"
end
after_sign_up_path_for(resource) click to toggle source

The path used after sign up. You need to overwrite this method in your own RegistrationsController.

# File app/controllers/devise/registrations_controller.rb, line 111
def after_sign_up_path_for(resource)
  after_sign_in_path_for(resource)
end
after_update_path_for(resource) click to toggle source

The default url to be used after updating a resource. You need to overwrite this method in your own RegistrationsController.

# File app/controllers/devise/registrations_controller.rb, line 126
def after_update_path_for(resource)
  signed_in_root_path(resource)
end
authenticate_scope!() click to toggle source

Authenticates the current scope and gets the current resource from the session.

# File app/controllers/devise/registrations_controller.rb, line 131
def authenticate_scope!
  send(:"authenticate_#{resource_name}!", force: true)
  self.resource = send(:"current_#{resource_name}")
end
build_resource(hash=nil) click to toggle source

Build a devise resource passing in the session. Useful to move temporary session data to the newly created user.

# File app/controllers/devise/registrations_controller.rb, line 99
def build_resource(hash=nil)
  self.resource = resource_class.new_with_session(hash || {}, session)
end
sign_up(resource_name, resource) click to toggle source

Signs in a user on sign up. You can overwrite this method in your own RegistrationsController.

# File app/controllers/devise/registrations_controller.rb, line 105
def sign_up(resource_name, resource)
  sign_in(resource_name, resource)
end
sign_up_params() click to toggle source
# File app/controllers/devise/registrations_controller.rb, line 136
def sign_up_params
  devise_parameter_sanitizer.sanitize(:sign_up)
end
translation_scope() click to toggle source
# File app/controllers/devise/registrations_controller.rb, line 144
def translation_scope
  'devise.registrations'
end
update_needs_confirmation?(resource, previous) click to toggle source
# File app/controllers/devise/registrations_controller.rb, line 85
def update_needs_confirmation?(resource, previous)
  resource.respond_to?(:pending_reconfirmation?) &&
    resource.pending_reconfirmation? &&
    previous != resource.unconfirmed_email
end
update_resource(resource, params) click to toggle source

By default we want to require a password checks on update. You can overwrite this method in your own RegistrationsController.

# File app/controllers/devise/registrations_controller.rb, line 93
def update_resource(resource, params)
  resource.update_with_password(params)
end