开发者

How do i get the rails default validation message?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜