エラーを発生させて、レジストレーションコントローラの編集ページを表示しようとしています。しかし、エラーが発生したときにページがフリーズし、このエラーが発生します。私はraise ActiveRecord:Rollback
私が望むようにそれが実際に変更をロールバックが、それは続行し、編集ページをレンダリングしていないことを打ったときRegistrationsControllerのテンプレートが見つかりません#update
No template found for RegistrationsController#update rendering head :no_content
Completed 204 No Content in 698ms (ActiveRecord: 2.3ms)
は、ここに私のコントローラのアクション
def update
resource.transaction do
super do |user|
if membership_params.present?
ToggleAlertEmails.perform(user: current_user, params: membership_params)
end
if user.errors[:current_password].present?
raise ActiveRecord::Rollback
redirect_to edit_user_registrations_path
end
end
end
end
です。どうすればこれを達成できますか?トランザクション外
この回答をスタックオーバーフローから参照することはできますが、質問を読むことを忘れないでください。状況はあなたのものと似ています。 [http://stackoverflow.com/questions/38460895/possible-to-render-and-raise-exception-in-rails-controller] – kparekh01