Skip to content

Commit

Permalink
Fixed incorrect examples of ActiveRecord error message lookup in the …
Browse files Browse the repository at this point in the history
…I18N guide [Thanks Alex Fortuna]

See http://www.ruby-forum.com/topic/179273
  • Loading branch information
karmi committed Mar 1, 2009
1 parent a6f1e42 commit 61656cf
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions railties/guides/source/i18n.textile
Original file line number Diff line number Diff line change
Expand Up @@ -705,20 +705,20 @@ end
The key for the error message in this case is +:blank+. Active Record will lookup this key in the namespaces:

<ruby>
activerecord.errors.messages.models.[model_name].attributes.[attribute_name]
activerecord.errors.messages.models.[model_name]
activerecord.errors.models.[model_name].attributes.[attribute_name]
activerecord.errors.models.[model_name]
activerecord.errors.messages
</ruby>

Thus, in our example it will try the following keys in this order and return the first result:

<ruby>
activerecord.errors.messages.models.user.attributes.name.blank
activerecord.errors.messages.models.user.blank
activerecord.errors.models.user.attributes.name.blank
activerecord.errors.models.user.blank
activerecord.errors.messages.blank
</ruby>

When your models are additionally using inheritance then the messages are looked up for the inherited model class names are looked up.
When your models are additionally using inheritance then the messages are looked up in the inheritance chain.

For example, you might have an Admin model inheriting from User:

Expand Down

0 comments on commit 61656cf

Please sign in to comment.