更新时间:2022-02-18 02:35:08
我会这样做:确保将其粘贴到 app / admin / admin_user.rb
文件。我不会直接添加控制器方法,而是会使用 member_action
dsl指令添加逻辑。
I would do it this way: make sure to paste this in the app/admin/admin_user.rb
file. I would not add controller methods directly but would use the member_action
dsl directive to add logic. Good luck!
action_item :reset_password, :only => :edit do
link_to 'Reset password', do_password_reset_admin_admin_user_path(resource), :method => :post
end
member_action :do_password_reset, :method => :post do
flash.notice = "A mail containing password reset instructions has been sent to: #{resource.email}"
resource.send_reset_password_instructions
redirect_to edit_admin_admin_user_path(resource) and return
end