Forum: Ruby on Rails Translation inside models?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Fdb488647484e40f785dde7134afc6d1?d=identicon&s=25 Heinz Strunk (cojones)
on 2009-04-23 13:43
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 method `t'

Is it not possible to translate text inside a model? If it is... how do
I do it the right way?
84fbb9c2a7b05c3ddf39904514585a90?d=identicon&s=25 Franco Catena (Guest)
on 2009-04-23 17:14
(Received via mailing list)
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 Catena.

On Apr 23, 8:43 am, Heinz Strunk <>
Fdb488647484e40f785dde7134afc6d1?d=identicon&s=25 Heinz Strunk (cojones)
on 2009-04-23 18:19
Thank you! Especially for remdinding me of the ability to override the
default messages :)
This topic is locked and can not be replied to.