[Rails] Re: I18n in model validations: Possible or not?
> It may work for the default "keys" (for "validates_presence_of :name"
> the key would be "blank"), but not the custom ones.
To sum it up: The solution is NOT to include any *custom* message keys
in the models, like...
:message =>
I18n.t('activerecord.errors.models.my_model.attributes.whatever.please_select_whatever')
The model will then apply the default message keys, for example
":inclusion" in the case of "validates_inclusion_of"
...and in config/locales/en.yml you need to have:
en:
activerecord:
errors:
models:
my_model:
attributes:
whatever:
inclusion: "Please select whatever." # see key:
"inclusion"
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home