1
我在用户验证的Rails应用程序中使用Devise。我已经创建了注册和会话控制器,但是现在我需要一个控制器来模拟来自脚手架的def update
。有没有办法访问Devise用来更新用户的控制器?设计的更新控制器
我在用户验证的Rails应用程序中使用Devise。我已经创建了注册和会话控制器,但是现在我需要一个控制器来模拟来自脚手架的def update
。有没有办法访问Devise用来更新用户的控制器?设计的更新控制器
是的,你也可以继承使用色器件编辑用户,做任何你想要的更新动作registrations_controller,这是与它的默认更新动作子类控制器:
class Users::RegistrationsController < Devise::RegistrationsController
def update
self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key)
if resource.update_with_password(params[resource_name])
set_flash_message :notice, :updated if is_navigational_format?
sign_in resource_name, resource, :bypass => true
respond_with resource, :location => after_update_path_for(resource)
else
clean_up_passwords(resource)
respond_with_navigational(resource){ render_with_scope :edit }
end
end
end
我认为就是图谋在注册控制器中执行用户更新 – binarycode