mirror of
https://github.com/heartcombo/devise.git
synced 2026-01-10 08:08:00 -05:00
Always get a new object on edit, update and delete.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user