0
我收到以下錯誤,當我創建從我形成一個新的對象:Can't mass-assign protected attributes: feature_ids
。在我的模型,我有以下:::加載ActiveModel :: MassAssignmentSecurity錯誤看不到的地方,使變量訪問
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從錯誤中訪問在我的舷外機模型我已經做功能訪問。
控制器所屬的窗體? – megas
您是否嘗試過'attr_accessible:make,:model,:price,:feature_ids'? –
爲什麼要打破慣例?爲什麼在那裏'has_many:Outboardfeature'而不是'has_many:outboard_features'?爲什麼當你可以推斷'belongs_to'時,你指定'class_name'和'foregin_key'? – jdoe