Ruby on rails 设计错误信息和路线4
我有一个编辑页面,与设计。要在我的应用程序中使用它,我需要呈现一个特殊的布局,该布局应该只在编辑页面中呈现。 所以为了覆盖我写的编辑方法。。 这是我的注册号Ruby on rails 设计错误信息和路线4,ruby-on-rails,ruby,ruby-on-rails-3,devise,Ruby On Rails,Ruby,Ruby On Rails 3,Devise,我有一个编辑页面,与设计。要在我的应用程序中使用它,我需要呈现一个特殊的布局,该布局应该只在编辑页面中呈现。 所以为了覆盖我写的编辑方法。。 这是我的注册号 def edit session[:tab] = "Edit Profile" render layout: 'calculator' end def update self.resource = resource_class.to_adapter.get!(send(:"current_#{resour
def edit
session[:tab] = "Edit Profile"
render layout: 'calculator'
end
def update
self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key)
prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)
p '----------------'
resource_updated = update_resource(resource, account_update_params)
yield resource if block_given?
if resource_updated
if is_flashing_format?
flash_key = update_needs_confirmation?(resource, prev_unconfirmed_email) ?
:update_needs_confirmation : :updated
set_flash_message :notice, flash_key
end
sign_in resource_name, resource, bypass: true
respond_with resource, location: after_update_path_for(resource)
else
clean_up_passwords resource
redirect to '/users/edit'
end
end
问题是,如果我输入了错误的密码,就会发生错误,渲染失败。
所以我想在我的更新功能中重定向到编辑url。问题是,当它重定向到编辑页面时,我也想显示错误消息
或者有什么简单的方法可以做到这一点。我想在编辑页面中呈现一个布局,当更新时出现错误(如密码不匹配)时,该布局不会中断
阅读了关于此问题的内容后,使用重定向\u至
似乎无法保持您在控制器中设置的闪存
键
要解决此问题,您可以使用:
系统 在我看来,你的系统效率很低——我知道你复制了Desive使用的文件,但它仍然臃肿
您还在控制器中使用
puts
?不您应该只在视图中输出数据
此问题可能是由于您使用了重定向
。我认为重定向调用会擦除闪存(如下所述:)
def update
...
else
flash.keep #-> added
...
redirect to '/users/edit'
end
end