Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/54.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
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 - Fatal编程技术网

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