ruby-on-railsglobalize3

globalize3 configuration I18n.locale variable


take a look into my model and my migration

i only have one attribute to test the globalize3 gem

class Car < ActiveRecord::Base
   attr_accessible :name
   translates :name
end

my migration looks like the following

class CreateCars < ActiveRecord::Migration
  def up
    create_table :cars do |t|
      t.timestamps
    end
    Car.create_translation_table! :name => :string
  end

  def down
    Car.drop_translation_table!
    drop_table :cars
  end
end

and i got the following error while trying to save new car details with the attribute name

ActiveModel::MassAssignmentSecurity::Error: Can't mass-assign protected attributes: locale

i think i am missing some declaration/configuration for globalize3 to access the I18n.locale variable.

btw i am using rails 3.2.3 and ruby 1.9.3p125


Solution

  • just found an workaround to my problem by following this Issue

    class Car < ActiveRecord::Base
      attr_accessible :name
      translates :name
      class Translation
        attr_accessible :locale
      end
    end