Forum: Ruby on Rails Localizing attributes when using I18n

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.
Colorblind (Guest)
on 2009-05-03 13:25
(Received via mailing list)
Currently I'm developing a multilingual app on rails 2.2. I liked very
much the idea of Xavier Defrang to provide a locale-aware accessor for
the fields that needs a translation:

I modified code a little to make it work with rails 2.2:

  def self.localize(*attribute_names)
    attribute_names.each do |attribute_name|
      class_eval %{
        def _#{attribute_name}
            localized_method = "#{attribute_name}_\#
            return send(localized_method.to_sym) if respond_to?

it works fine for :show, :index, :new. But when I'm trying to create
or update, I get the following error:

    ActiveRecord::UnknownAttributeError in NewsitemsController#create

    unknown attribute: _body

What's wrong? Please, help.
Colorblind (Guest)
on 2009-05-03 17:53
(Received via mailing list)
This topic is locked and can not be replied to.