Rails 3 ActiveModel 嵌套类 I18n
给定 ruby 中的以下类定义:
class Conversation
class Message
include ActiveModel::Validations
attr_accessor :quantity
validates :quantity, :presence => true
end
end
How can you use i18n to customize to error message。 例如,Conversation 类的正确查找应该是
activemodel:
errors:
models:
conversation:
attributes:
quantity:
blank: "Some custom message"
但是 Message 类的它是什么? 我尝试过:
activemodel:
errors:
models:
conversation:
message:
attributes:
quantity:
blank: "Some custom message"
activemodel:
errors:
models:
message:
attributes:
quantity:
blank: "Some custom message"
activemodel:
errors:
models:
conversation::message:
attributes:
quantity:
blank: "Some custom message"
没有一个有效 有什么想法或者这是 ActiveModel 或 I18n 的错误吗?
Given the following class definition in ruby:
class Conversation
class Message
include ActiveModel::Validations
attr_accessor :quantity
validates :quantity, :presence => true
end
end
How can you use i18n to customize to error message.
For example the correct lookup for the class Conversation would be
activemodel:
errors:
models:
conversation:
attributes:
quantity:
blank: "Some custom message"
But what is it for the Message class?
I tried:
activemodel:
errors:
models:
conversation:
message:
attributes:
quantity:
blank: "Some custom message"
activemodel:
errors:
models:
message:
attributes:
quantity:
blank: "Some custom message"
activemodel:
errors:
models:
conversation::message:
attributes:
quantity:
blank: "Some custom message"
None of them work
Any ideas or is this a bug with ActiveModel or I18n?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 / 表示命名空间
Use a / for namespaces