0

从表单创建新对象时出现以下错误: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,因为在我的 Outboard 模型中我已经使功能可以访问。

4

1 回答 1

1

添加:feature_ids到舷外模型attr_accessible

于 2012-07-02T14:18:25.997 回答