在我的 Rails 应用程序中,我在我的事件记录对象中使用了验证助手,它们非常棒。当出现问题时,我会在我的网页上看到标准的“3 个错误禁止保存此 foobar”以及个别问题。
有什么方法可以用我自己的方式覆盖这个默认消息吗?
最佳答案
用于显示错误的 error_messages_for
助手接受一个 :header_message
选项,该选项允许您更改默认标题文本。如:
error_messages_for 'model', :header_message => "You have some errors that prevented saving this model"
RubyOnRails API是你的 friend 。
关于ruby-on-rails - 如何在 Rails 中更改 "3 errors prohibited this foobar from being saved"验证消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/125512/