Forum: Ruby on Rails gettext in 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.
B6e90ad1e69d563f1f13cccffe137262?d=identicon&s=25 Simon.Santoro (Guest)
on 2005-11-19 17:07
(Received via mailing list)
i would like to translate the error messages in my models like this:

class Person < ActiveRecord::Base
   validates_presence_of :name, :message => _('Please insert a name')

but i get
undefined method `_' for Person:Class

why? can i change this behaviour?

btw, it would also be nice if there was a
ActiveRecord::Errors.full_messages() without the
@base.class.human_attribute_name(attr), so i would be able to translate
the whole message.
9fe908f5593444a40be14a424c372e58?d=identicon&s=25 mutoh (Guest)
on 2005-11-19 20:19
(Received via mailing list)

On Sat, 19 Nov 2005 17:04:46 +0100
Simon Santoro <> wrote:

> why? can i change this behaviour?

include GetText::Rails  #You can call this on another file once
                        #such as config/environment.rb after requiring
class Article < ActiveRecord::Base
  validates_presence_of :description, :message => _('Please insert a
B6e90ad1e69d563f1f13cccffe137262?d=identicon&s=25 Simon.Santoro (Guest)
on 2005-11-19 20:23
(Received via mailing list)
Masao Mutoh wrote:
Thank you Masao! For the second time :)
Thanks for being on the list, and thanks for making rgettext
This topic is locked and can not be replied to.