How to localize activerecord model value with Rails 3
I want to localize model values within form helpers.
For ex开发者_Python百科ample I have 2 models, Role and User, defined by the relation : role has_many users.
To create a new user I have in my controller something like this :
@user = User.new @roles = Role.all # role title return values "admin" or "customer" only
And in my form I have something like this :
f.collection_select :role_id, @roles, :id, :title, {:selected => (@user.role)}
How can I localize role title values?
I used to set my localization in config/locales files. Can I set activerecord model values in this way?
Thank you for your help!
Jeremy.
Globalize2 is one solution for data i18n. I've not used it though, so don't ask me if it eats your wife.
精彩评论