我已阅读了关于此问题的一些SO文章,但没有一篇似乎在工作。我为我的一个表创建种子数据,每当我耙运行分贝:种子它给我的错误:无法批量分配受保护的属性
Can't mass-assign protected attributes: severity
我的两个车型看起来像
class Status < ActiveRecord::Base
belongs_to :severity
attr_accessible :description, :image, :name, :slug, :severity_id
end
和
class Severity < ActiveRecord::Base
attr_accessible :name, :val, :severity_id
end
我试图播种的数据是
statuses = Status.create(
[
{
"name"=> 'Normal',
"slug"=> 'normal',
"description"=> 'The service is up or was up during this entire period',
"severity"=> 1,
"image"=> 'tick-circle'
}
]
)
我正在努力理解为什么会发生这种情况。有什么建议吗?
在此先感谢
谢谢,完全看到我现在出错的地方。 – xyzjace 2013-05-11 02:42:53