开发者

Rails 3 ActiveModel Nested Class 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 I1开发者_如何学编程8n?


Use a / for namespaces

activemodel:
  errors:
    models:
      conversation/message:
        attributes:
          quantity:
            blank: "Some custom message"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜