У меня есть приложение Rails 3.2, и у меня есть следующая модель, где у нас есть два уровня accept_nested_attributes_for
class AdSource < ActiveRecord::Base
has_many :prices, dependent: :destroy
accepts_nested_attributes_for :prices, allow_destroy: true
attr_accessible :price_attributess
end
class Price < ActiveRecord::Base
belongs_to :ad_source
has_many :price_attributes, dependent: :destroy
accepts_nested_attributes_for :price_attributes, allow_destroy: true
attr_accessible :price_attributes_attributes
end
class PriceAttribute < ActiveRecord::Base
belongs_to :price
end
Когда я выполняю http-код следующего:
{"ad_source"=>{"name"=>"blue is cool", "cpm"=>"2", "id"=>"210", "price_attributes"=>[{"name" => "my something", "id"=>"88", "_destroy"=>"1", "price_attributes_attributes"=>[{"id"=>"88", "network_attribute_value"=>"i am here"}]}]},
"id"=>"210",
}
оноудаляет цену с помощью _destroy: 1
, но позволяет привязанным связанным атрибутам price_attributes.Это похоже на ошибку;я должен отправить _destroy: 1
для обоих объектов?Или есть какой-нибудь способ сказать Rails уничтожить?