我有一个关联
class DeliveryVehicle < ApplicationRecord
has_many :compartments
validates :compartments, presence: true
accepts_nested_attribtues_for :compartments, allow_destroy: true
end
在控制器中。我正在尝试使用创建记录
DeliveryVehicle.create!(name: "Ford", compartments_attributes: {slug: 'comp1', length: 2})
上面的创建抛出了一个错误,说应该存在用于送货车的隔间。
是否有拼写错误?
accepts_nested_attribtues_for
,应为:accepts_nested_attributes_for