3

考慮下面的類定義中的紅寶石:Rails的加載ActiveModel 3嵌套類的I18n

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

如何使用國際化,以自定義錯誤消息。 例如,對於類對話的正確查找就

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"