我想提出一个错误,然后渲染注册控制器的编辑页面。但是当我遇到错误页面冻结,我得到这个错误。没有发现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