开发者

How do i get the rails default validation message?

开发者 https://www.devze.com 2023-04-11 17:03 出处:网络
How i can get the default error message in rails for example The default rails validation failed message for blank is \"can\'t be blank\"

How i can get the default error message in rails

for example

The default rails validation failed message for blank is "can't be blank"

how i can get these val开发者_开发百科idation message in rails 3 .

In Rails < 3.0 we can use ActiveRecord::Error.default_error_messages[:taken]

but it doesn't work in rails 2


You can get it with I18n

irb(main):0> I18n.t 'activerecord.errors.messages.taken'
=> "has already been taken"
0

精彩评论

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

关注公众号