Class: Devise::RegistrationsController
- Inherits:
-
DeviseController
- Object
- DeviseController
- Devise::RegistrationsController
- Defined in:
- app/controllers/devise/registrations_controller.rb
Instance Method Summary collapse
-
#cancel ⇒ Object
GET /resource/cancel Forces the session data which is usually expired after sign in to be expired now.
-
#create {|resource| ... } ⇒ Object
POST /resource.
-
#destroy {|resource| ... } ⇒ Object
DELETE /resource.
-
#edit ⇒ Object
GET /resource/edit.
-
#new ⇒ Object
GET /resource/sign_up.
-
#update {|resource| ... } ⇒ Object
PUT /resource We need to use a copy of the resource because we don’t want to change the current user in place.
Methods inherited from DeviseController
#_prefixes, #devise_mapping, #resource, #resource_class, #resource_name, #signed_in_resource
Instance Method Details
#cancel ⇒ Object
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.
75 76 77 78 |
# File 'app/controllers/devise/registrations_controller.rb', line 75 def cancel expire_data_after_sign_in! redirect_to new_registration_path(resource_name) end |
#create {|resource| ... } ⇒ Object
POST /resource
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/devise/registrations_controller.rb', line 12 def create build_resource(sign_up_params) resource_saved = resource.save yield resource if block_given? if resource_saved if resource.active_for_authentication? :notice, :signed_up if is_flashing_format? sign_up(resource_name, resource) respond_with resource, location: after_sign_up_path_for(resource) else :notice, :"signed_up_but_#{resource.}" 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 respond_with resource end end |
#destroy {|resource| ... } ⇒ Object
DELETE /resource
62 63 64 65 66 67 68 |
# File 'app/controllers/devise/registrations_controller.rb', line 62 def destroy resource.destroy Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name) :notice, :destroyed if is_flashing_format? yield resource if block_given? (resource){ redirect_to after_sign_out_path_for(resource_name) } end |
#edit ⇒ Object
GET /resource/edit
34 35 36 |
# File 'app/controllers/devise/registrations_controller.rb', line 34 def edit render :edit end |
#new ⇒ Object
GET /resource/sign_up
6 7 8 9 |
# File 'app/controllers/devise/registrations_controller.rb', line 6 def new build_resource({}) respond_with self.resource end |
#update {|resource| ... } ⇒ Object
PUT /resource We need to use a copy of the resource because we don’t want to change the current user in place.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/controllers/devise/registrations_controller.rb', line 41 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 :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 |