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: 
http://defrang.com/articles/2005/12/02/playing-with-rails-i18n

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}_\#
{I18n.locale.to_s}"
            return send(localized_method.to_sym) if respond_to?
(localized_method)
          #{attribute_name}
        end
      }
    end
  end

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.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to