Dean
Dean

Reputation: 8998

ActiveModel::MassAssignmentSecurity::Error can't see where to make variable accessible

I am getting the following error when I create a new object from my form: Can't mass-assign protected attributes: feature_ids. In my models I have the following:

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

I can't see where to make the feature_ids accessible from the error as in my Outboard model I have made features accessible.

Upvotes: 0

Views: 329

Answers (1)

Dean
Dean

Reputation: 8998

Add :feature_ids to the Outboard Models attr_accessible.

Upvotes: 1

Related Questions