Ruby on rails Rails 4,cocoon gem销毁创建的对象
我的申请有一个大问题。这有点复杂,所以我会试着深入解释。在我的应用程序中,我有一个汽车模型:Ruby on rails Rails 4,cocoon gem销毁创建的对象,ruby-on-rails,ruby-on-rails-3,ruby-on-rails-4,ruby-on-rails-3.2,cocoon-gem,Ruby On Rails,Ruby On Rails 3,Ruby On Rails 4,Ruby On Rails 3.2,Cocoon Gem,我的申请有一个大问题。这有点复杂,所以我会试着深入解释。在我的应用程序中,我有一个汽车模型: class Car < ActiveRecord::Base has_many :prices, dependent: :destroy accepts_nested_attributes_for :prices, allow_destroy: true end 和价格字段: .nested-fields %table.table.table-striped.table-bo
class Car < ActiveRecord::Base
has_many :prices, dependent: :destroy
accepts_nested_attributes_for :prices, allow_destroy: true
end
和价格字段:
.nested-fields
%table.table.table-striped.table-bordered
%thead
%th
= f.input :from_days
%th
= f.input :to_days
%th
= f.input :netto_price
= link_to_remove_association "X", f
问题是,当我创建一些价格并进入下一步时,价格被保存到数据库中,一切正常。但当我回到这一步并单击我的:
= link_to_remove_association "X", f
它仅隐藏此对象,而不从数据库中删除它。这对我来说是个大问题。我找不到问题。如果可以,请提供帮助。我将我的“价格”字段更改为:
.nested-fields
%table.table.table-striped.table-bordered
%thead
%th
= f.input :from_days
%th
= f.input :to_days
%th
= f.input :netto_price
= link_to_remove_association "X", f
我的链接到删除关联这是一个层次太深了。。。
现在很有魅力没人知道答案?
= link_to_remove_association "X", f
.nested-fields
%table.table.table-striped.table-bordered
%thead
%th
= f.input :from_days
%th
= f.input :to_days
%th
= f.input :netto_price
= link_to_remove_association "X", f