mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Always get a new object on edit, update and delete.
This commit is contained in:
parent
0e64bc74b7
commit
901c6ae4df
1 changed files with 6 additions and 6 deletions
|
@ -30,28 +30,28 @@ class Devise::RegistrationsController < ApplicationController
|
|||
|
||||
# PUT /resource
|
||||
def update
|
||||
if self.resource.update_with_password(params[resource_name])
|
||||
if resource.update_with_password(params[resource_name])
|
||||
set_flash_message :notice, :updated
|
||||
redirect_to after_sign_in_path_for(self.resource)
|
||||
else
|
||||
build_resource
|
||||
send(:"current_#{resource_name}").reload
|
||||
render_with_scope :edit
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /resource
|
||||
def destroy
|
||||
self.resource.destroy
|
||||
resource.destroy
|
||||
set_flash_message :notice, :destroyed
|
||||
sign_out_and_redirect(self.resource)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# Authenticates the current scope and dup the resource
|
||||
# Authenticates the current scope and gets a copy of the current resource.
|
||||
# We need to use a copy because we don't want actions like update changing
|
||||
# the current user in place.
|
||||
def authenticate_scope!
|
||||
send(:"authenticate_#{resource_name}!")
|
||||
self.resource = send(:"current_#{resource_name}")
|
||||
self.resource = resource_class.find(send(:"current_#{resource_name}").id)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue