Class: LocalDevise::RegistrationsController

Inherits:
Devise::RegistrationsController
  • Object
show all
Defined in:
app/controllers/local_devise/registrations_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

NOTE: some functionality has been removed for this project - check parent controller


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/local_devise/registrations_controller.rb', line 5

def create
  build_resource()
  resource.role = User.user_role

  if resource.save
    if resource.active_for_authentication?
      (resource_name, resource)
      
      set_msg t(:signed_up, :scope => 'devise.registrations')
    else
      set_msg t(:"signed_up_but_#{resource.inactive_message}", :scope => 'devise.registrations')
      expire_data_after_sign_in!
    end
  else
    clean_up_passwords resource
    respond_to do |format|
      format.js { render :action => "failed_new" }
    end
  end
end

#updateObject

Comment from Devise parent controller: We need to use a copy of the resource because we don't want to change the current user in place.


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/local_devise/registrations_controller.rb', line 29

def update
  self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key)

  if resource.update_with_password(resource_params)
     resource_name, resource, :bypass => true
    if resource.email_unconfirmed?
      set_msg t(:updated_email, :scope => 'myinfo.devise.messages')
    else
      set_msg t(:updated, :scope => 'devise.registrations')
    end
  else
    clean_up_passwords resource
    respond_to do |format|
      format.js { render :action => "failed_edit" }
    end
  end
end