3

Учитывая следующее определение класса в рубине:Rails 3 ActiveModel Вложенный класс I18n

class Conversation 
    class Message 
    include ActiveModel::Validations 
    attr_accessor :quantity 
    validates :quantity, :presence => true 
    end 
end 

Как вы можете использовать i18n для настройки ошибки сообщения. Например правильный поиск для класса Разговор будет

activemodel: 
    errors: 
    models: 
     conversation: 
     attributes: 
      quantity: 
      blank: "Some custom 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?

ответ

4

Используйте/для пространств имен

activemodel: 
    errors: 
    models: 
     conversation/message: 
     attributes: 
      quantity: 
      blank: "Some custom message" 
Смежные вопросы