Hi everyone. I was trying to customize AR validation error messages and came across this kind of message lookup order, which EVERY I18n guide in existence seems to be giving: ~~~ activerecord.errors.messages.models.user.attributes.name.blank activerecord.errors.messages.models.user.blank activerecord.errors.messages.blank ~~~ I tried to follow that, but, to my surprise, only least-detailed variant worked: "activerecord.errors.messages.blank". After a bit of research I've found out that lookup paths for Rails 2.2.2 are different from what's stated above. I.e. the ACTUAL paths being used are: ~~~ activerecord.errors.models.user.attributes.name.blank activerecord.errors.models.user.blank activerecord.errors.messages.blank ~~~ My test localization yaml is (model name is 'script'): ~~~ en: activerecord: errors: messages: blank: I'm errors.messages.blank models: script: # As documented, doesn't work. blank: I'm errors.messages.models.script.blank attributes: name: # As documented, doesn't work. blank: I'm errors.messages.models.script.attributes.name.blank models: script: # Not as documented, but it works. blank: I'm errors.MODELS.script.blank attributes: name: # Not as documented, but it works. blank: I'm errors.MODELS.script.attributes.name.blank ~~~ That kind of discrepancy in I18n guides seems rather serious to me, so I'm asking everyone who's in contact with guide authors or wikis to fix AR message lookup paths in documentation. If that's a confusion or version mismatch on my side, please correct me. I'm using Rails 2.2.2. Here are some guide links that seem to be WRONG: http://guides.rails.info/i18n.html http://rails-i18n.org/wiki/pages/i18n-rails-guide (and more, just search for 'activerecord.errors.messages.models.user') This page is RIGHT on lookup order: http://api.rubyonrails.org/classes/ActiveRecord/Errors.html Alex
on 2009-02-21 01:08
on 2009-03-20 17:33
Thanks for pointing this out. Saved my day.
on 2009-03-20 17:38
Mr. Ronald wrote: > Thanks for pointing this out. Saved my day. Guide at guides.rails.info has already been fixed by guide maintainer, Karel.
on 2009-03-20 17:51
But isn't there still an error in http://rails-i18n.org/wiki/pages/i18n-rails-guide activerecord.errors.messages.models.user.attributes.name.blank which should be activerecord.errors.models.user.attributes.name.blank right?
on 2009-03-21 23:08
On Fri, Mar 20, 2009 at 5:51 PM, Mr. Ronald <firstname.lastname@example.org> wrote: > But isn't there still an error in > http://rails-i18n.org/wiki/pages/i18n-rails-guide Yeah don't rely on that page, it is just draft. The i18n guide is at http://guides.rubyonrails.org/i18n.html.