ActiveModel :: MassAssignmentSecurity :: Error无法查看使变量可访问的位置

时间:2012-06-14 20:33:43

标签: ruby-on-rails ruby-on-rails-3 activerecord

从表单创建新对象时出现以下错误:Can't mass-assign protected attributes: feature_ids。在我的模型中,我有以下内容:

class Outboard < ActiveRecord::Base
  attr_accessible :make, :model, :price, :features
  has_many :features, :through => :Outboardfeature
  has_many :Outboardfeature
end

class Feature < ActiveRecord::Base
  attr_accessible :name
  has_many :outboards, :through => :Outboardfeature
  has_many :Outboardfeature
end

class Outboardfeature < ActiveRecord::Base
  attr_accessible :feature_id, :outboard_id
  belongs_to :feature, :class_name => "Feature", :foreign_key => "feature_id"
  belongs_to :outboard, :class_name => "Outboard", :foreign_key => "outboard_id"
end

我无法看到从错误中可以访问feature_ids的位置,就像我的外置模型中我可以访问的功能一样。

1 个答案:

答案 0 :(得分:1)

:feature_ids添加到外接模特attr_accessible