我想提出一個錯誤,然後渲染註冊控制器的編輯頁面。但是當我遇到錯誤頁面凍結,我得到這個錯誤。沒有發現RegistrationsController的模板#更新
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
當我打的raise ActiveRecord:Rollback
它實際上回滾的變化就像我想,但它並沒有繼續和呈現編輯頁面。我怎樣才能做到這一點?
您可能想從堆棧溢出中引用此答案,但請務必閱讀該問題,情況與您的情況類似。 [http://stackoverflow.com/questions/38460895/possible-to-render-and-raise-exception-in-rails-controller] – kparekh01