开发者

Rails I18n Errors

开发者 https://www.devze.com 2023-02-26 06:59 出处:网络
I am reading I18N for Active Record Models but I can\'t get an attribute on my model to display correctly.

I am reading I18N for Active Record Models but I can't get an attribute on my model to display correctly.

I have a model like this:

class Tran < ActiveRecord::Base
    validates :description, :presence => true,
                            :length => {:maximum => 100 }
end

and a en.yml file like this:

en:
  activerecord:
    attributes:
      tran:
        description: "Description"
    errors:
      models:
        tran:
          attributes:
            description:
  errors:
    messages:
      blank: "can't be blank!"

When I show the error message on the client, the "can't be blank!" successfully shows up, but the description does not change to "Description" like I would expect. What am I doing wrong?

Thanks开发者_Python百科.


This is pretty relevant to what you want :

How to change validation messages on forms

0

精彩评论

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

关注公众号