cocoon gem 无法删除嵌套字段图像

cocoon gem can't remove nested field image

我已经正确设置了 cocoon gem 并且一切正常,我可以根据需要上传图像,但是当我点击删除时,它似乎并没有删除图像。这是我的代码:

_image_fields.html.erb

<div class="nested-fields">
  <%= f.text_area :description %>
  <%= f.file_field :picture %>
  <%= link_to_remove_association "remove", f %>
</div>

这是我的表格:

<div class="imagefield">
  <h2>Images</h2>
    <h4>upload images</h4>
      <hr>
       <div class="customgap">
         <div class="images">
           <%= f.fields_for :images do |image| %>
             <%= render 'image_fields', f: image  %>
           <% end %>
          <div class="links">
            <%= link_to_add_association 'add image', f, :images %>
          </div>
         </div>
       </div>
     </div>

在控制器中:

images_attributes: [:id, :description, :picture, :_destroy]

图片模型

class Image < ActiveRecord::Base

  has_attached_file :picture, styles: { medium: "300x300>", thumb: "100x100>" }
  validates_attachment_content_type :picture, content_type: /\Aimage\/.*\Z/
end

我不得不在控制器中:allow_destroy => true

accepts_nested_attributes_for :images, :allow_destroy => true