如何更改“3个错误禁止保存此foobar"Rails 中的验证消息? [英] How to change "3 errors prohibited this foobar from being saved" validation message in Rails?
问题描述
在我的 rails 应用程序中,我在活动记录对象中使用了验证助手,它们很棒.当出现问题时,我会在我的网页上看到标准的3 个错误禁止保存此 foobar"以及个别问题.
In my rails app I use the validation helpers in my active record objects and they are great. When there is a problem I see the standard "3 errors prohibited this foobar from being saved" on my web page along with the individual problems.
有什么办法可以用我自己的消息覆盖这条默认消息吗?
Is there any way I can override this default message with my own?
推荐答案
您用来显示错误的 error_messages_for
助手接受一个 :header_message
选项,允许您更改该默认标题文本.如:
The error_messages_for
helper that you are using to display the errors accepts a :header_message
option that allows you to change that default header text. As in:
error_messages_for 'model', :header_message =>您有一些错误导致无法保存此模型"
RubyOnRails API 是您的朋友.
这篇关于如何更改“3个错误禁止保存此foobar"Rails 中的验证消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!