Translation inside models?

Hey people,

I’m having a problem translating messages inside a model, e.g. I used to
have it like this:

validates_uniqueness_of :username, :message => “Username in use already”

which worked fine but now I wanna internationalize my application and
thought it’d work like everywhere else in my application and I did

validates_uniqueness_of :username, :message => (t :username_in_use)

and I get: method_missing': undefined methodt’

Is it not possible to translate text inside a model? If it is… how do
I do it the right way?

Inside a model is used like this:


You can also put it in the translation yml like this:

taken: “ya está en uso”

There are more examples in:


Franco C…

On Apr 23, 8:43 am, Heinz S. [email protected]

Thank you! Especially for remdinding me of the ability to override the
default messages :slight_smile:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs