2010-12-03 71 views
2

如何處理我的自定義錯誤驗證的翻譯?我可以傳遞一個符號然後在我的yaml文件中做些什麼嗎? 這裏是我的代碼:國際化自定義模型錯誤

def validate 
    errors.add(:kind, "something i want to translate") unless KINDS.include?(kind) 
    end 

格雷格

回答

0

我發現了。

errors.add(:kind, I18n.t(:key, :scope => [:activerecord, :model]) unless KINDS.include?(kind)