看看我的模型和迁移
我只有一个属性来测试globalize3创业板
class Car < ActiveRecord::Base
attr_accessible :name
translates :name
end我的迁移如下所示
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当我试图用属性名保存新车详细信息时,我得到了以下错误
ActiveModel::MassAssignmentSecurity::Error:不能大规模分配受保护的属性: locale
我想我缺少一些用于globalize3访问I18n.locale变量的声明/配置。
顺便说一下,我使用的是rails 3.2.3和ruby 1.9.3p125
发布于 2012-04-13 10:15:00
通过遵循这个问题,我找到了一个解决问题的方法
class Car < ActiveRecord::Base
attr_accessible :name
translates :name
class Translation
attr_accessible :locale
end
end发布于 2012-05-13 11:17:59
这不是应该是:
class Car < ActiveRecord::Base
attr_accessible :name, :translations_attributes
translates :name
end请参见:
https://stackoverflow.com/questions/10134380
复制相似问题