开发者

Internationalize custom model errors

How can I handle translation of my custom errors validation? Can I pass a symbol and then do something in my yaml files? 开发者_如何学GoHere is my code:

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

Greg


I found out.

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜