カスタム コントローラ アクションに関するActiveAdmin のドキュメントを参照してください。「member_action」(単一のレコードに作用するカスタム コントローラー アクション) を作成し、それを実行する「action_item」を追加することでこれを実現しました (これらは、レコードを表示するときに右上に表示されるボタンです)。これが私がそれを機能させる方法です:
# in app/admin/admin_users.rb
action_item do
# Link to perform the member_action, "reset_password" defined below
link_to("Reset Password", reset_password_admin_admin_user_path(admin_user))
end
member_action :reset_password do
# Find the user in question
admin_user = AdminUser.find(params[:id])
# Call the method (from Devise) which sends them a password reset email
admin_user.send_reset_password_instructions
# Redirect back to the user's page with a confirmation
redirect_to(admin_admin_user_path(admin_user),
notice: "Password reset email sent to #{admin_user.email}")
end