自定义 i18n 错误消息会抛出 InvalidPluralizationData 错误?
我有一个“用户”和一个“个人资料”模型。用户与个人资料具有一对一的关系,并且 “接受_嵌套_属性_用于配置文件”。
我正在使用两个复选框验证配置文件 - 也就是说,在验证之前必须接受其中一项协议。
无论如何,我想自定义不接受其中一个框的错误消息,因此我将以下内容添加到 en.yml 中,
activerecord:
attributes:
user:
profile:
terms_and_conditions_a:
accepted: "You must accept the terms and conditions to continue"
terms_and_conditions_b:
accepted: "You must accept the terms and conditions to continue"
您将看到配置文件嵌套在用户下 - 这是为了阻止将“配置文件”放在前面错误消息 (如此处解释)。
这给出我的错误:
I18n::InvalidPluralizationData
translation data {:terms_and_conditions_a=>{:invalid=>"You must accept the terms and conditions to continue"}} can not be used with :count => 1
我真的不明白它试图复数什么,有什么帮助吗?
I have a 'user' and a 'profile' model. The user has one to one relationship with profile and
"accepts_nested_attributes_for profile".
I'm validating profile with two checkboxes - that is to say one of the agreements must be accepted before it's validated.
Anyway, I want to customise the error message for not accepting one of the boxes so I added the following into en.yml
activerecord:
attributes:
user:
profile:
terms_and_conditions_a:
accepted: "You must accept the terms and conditions to continue"
terms_and_conditions_b:
accepted: "You must accept the terms and conditions to continue"
You'll see that profile is nested under user - this is to stop "Profile" being put at the front of the error message (as explained here).
This gives me the error:
I18n::InvalidPluralizationData
translation data {:terms_and_conditions_a=>{:invalid=>"You must accept the terms and conditions to continue"}} can not be used with :count => 1
I don't really see what it's trying to pluralize, any help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许应该是
而不是
?
这就是我的应用程序中的情况,无可否认,它是 Rails 2 而不是 Rails 3。
或者,尝试不在用户下嵌套配置文件:
Maybe it should be
rather than
?
That's how it is in my app, which is admittedly rails 2 rather than rails 3.
Alternately, try not nesting profile under user: