views:

18

answers:

1

Hi all. I'm trying to override the string used to describe the 'login' attribute of my User model to be "User name" instead. I thought that this was set in vendor/rails/activerecord/lib/active_record/locale/en.yml. I've tried changing it here and in my config/locales/en.yml file, and in neither case does it work (i restart the server after every change).

In both cases it's done like this:

en:
...
  activerecord:
    attributes:
         user:
           login: User Name

When i test it out, eg having f.label :login in my new user form, it comes out as "Login" not "User Name". Am i labouring under some fundamental error about how this stuff works, or is it genuinely not working? Either way, can anyone tell me how to fix it? thanks, max

A: 

You may store your "User Name" string under any name in your en.yml file:

en:
 user:
   user_name: User Name

and in your view

<%= f.label :login, t('user.user_name') %> 
Yannis
Hi yannis. I know that i can make my own custom translations, but my understanding was that i could override the ones generated by rails so that i don't have to reference any custom translations at all: they get used automatically. I could be wrong about that.
Max Williams
That would be really interesting… please post a comment here if you find a solution elsewhere.
Yannis