Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.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 嵌套表单删除不起作用_Ruby On Rails_Ruby_Ruby On Rails 3.1_Nested Forms - Fatal编程技术网

Ruby on rails 嵌套表单删除不起作用

Ruby on rails 嵌套表单删除不起作用,ruby-on-rails,ruby,ruby-on-rails-3.1,nested-forms,Ruby On Rails,Ruby,Ruby On Rails 3.1,Nested Forms,我使用嵌套的_表单来添加和删除嵌套的_属性 class Text < ActiveRecord::Base attr_accessible :attachments_attributes has_many :attachments, :as => :attachable accepts_nested_attributes_for :attachments end 更新方法中参数的输出为 attachments_attributes: '0': descrip

我使用嵌套的_表单来添加和删除嵌套的_属性

class Text < ActiveRecord::Base
  attr_accessible :attachments_attributes
  has_many :attachments, :as => :attachable
  accepts_nested_attributes_for :attachments
end
更新方法中参数的输出为

attachments_attributes:
  '0':
    description: asdf asdf as fs
    _destroy: '1'
    id: '2'
  '1':
    description: ''
    _destroy: '1'
    id: '3'
  '2':
    description: asdsadasd
    _destroy: '1'
    id: '4'
我找不到问题,你知道哪里出了问题吗

谢谢大家!!
如果有不清楚的地方,请留言

添加
:允许销毁=>true
接受:附件的嵌套属性

accepts_nested_attributes_for :attachments, :allow_destroy => true

更多信息

添加
:允许销毁=>true
接受:附件的嵌套属性

accepts_nested_attributes_for :attachments, :allow_destroy => true
更多信息

accepts_nested_attributes_for :attachments, :allow_destroy => true