views:

287

answers:

1

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?

+1  A: 

Use a / for namespaces

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