Ruby on rails globalize3配置I18n.locale变量
看看我的模型和我的迁移 我只有一个属性来测试globalize3gemRuby on rails globalize3配置I18n.locale变量,ruby-on-rails,globalize3,Ruby On Rails,Globalize3,看看我的模型和我的迁移 我只有一个属性来测试globalize3gem class Car < ActiveRecord::Base attr_accessible :name translates :name end class-Car
class Car < ActiveRecord::Base
attr_accessible :name
translates :name
end
class-Car
我的迁移如下所示
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
class CreateCars:字符串
终止
降下
车,放下桌子!
升降台:汽车
终止
终止
在尝试使用属性名保存新车详细信息时,我遇到了以下错误
ActiveModel::MassAssignmentSecurity::错误:无法批量分配受保护的属性:区域设置
我想我缺少globalize3访问I18n.locale变量的一些声明/配置
顺便说一句,我使用的是rails 3.2.3和ruby 1.9.3p125,我刚刚找到了解决问题的方法
class-Car
通过以下步骤,我找到了解决问题的方法
class-Car
这不应该是:
class Car < ActiveRecord::Base
attr_accessible :name, :translations_attributes
translates :name
end
class-Car
见:
这不应该是这样的吗:
class Car < ActiveRecord::Base
attr_accessible :name, :translations_attributes
translates :name
end
class-Car
见:
我为rails 4找到的唯一解决方案我为rails 4找到的唯一解决方案