Ruby on rails RAILS:-仅销毁擦除记录(不删除)

Ruby on rails RAILS:-仅销毁擦除记录(不删除),ruby-on-rails,ruby,paperclip,ruby-on-rails-5,Ruby On Rails,Ruby,Paperclip,Ruby On Rails 5,自行车.rb has_many :pictures, as: :imageable accepts_nested_attributes_for :pictures, allow_destroy: true, :reject_if => proc { |obj| obj.blank? } belongs_to :imageable, polymorphic: true has_attached_file :image validates_attachment_conte

自行车.rb

  has_many :pictures, as: :imageable
  accepts_nested_attributes_for :pictures, allow_destroy: true, :reject_if => proc { |obj| obj.blank? }
  belongs_to :imageable, polymorphic: true
  has_attached_file :image
  validates_attachment_content_type :image, :content_type => ["image/jpg", "image/jpeg", "image/png"]
图片.rb

  has_many :pictures, as: :imageable
  accepts_nested_attributes_for :pictures, allow_destroy: true, :reject_if => proc { |obj| obj.blank? }
  belongs_to :imageable, polymorphic: true
  has_attached_file :image
  validates_attachment_content_type :image, :content_type => ["image/jpg", "image/jpeg", "image/png"]
编辑视图

<% @bicycle.pictures.each do |pic| %>
              <%= bicycle_form.fields_for :pictures, pic do |frm| %>
              <div class="col-lg-2">
                  <%= image_tag pic.image.url, class: 'edit-image-thumb'%>
                  Delete: <%= frm.check_box :_destroy %>
              </div>
              <% end %>
            <% end %>
问题:

据我所知,
\u destroy
复选框必须删除数据库中的整个记录(图片记录),但它只是删除
图像文件名
图像内容类型
图像文件大小
列值,但记录仍然存在

说明:


我有一辆自行车,它有许多自行车。所以,当我创造新的自行车,我可以附加许多图片。如果我想删除它们,我将进入
编辑
查看并选中要删除图片的复选框。但是图片记录不会从数据库中删除,只需清除列
image\u file\u name
image\u content\u type
image\u file\u size
将它们保留为空,但列(在同一记录中)
imageable\u type
id
仍然有值。因此,图像显示出来了(它仍然存在),但就像丢失一样(记录存在,但图像名称字段为零)

这里真的不清楚您要的是什么。你是想破坏两个记录,还是只破坏检查过的图片?@tadman only picture。您可以理解,因为我正在使用frm(即图片字段)变量生成check_boxSure,但您在问题“Bicycle-仍然存在”中特别抱怨,好像这是个问题。@tadman,Bicycle-它是可成像类型。多态关联请包括控制器的代码。这里不清楚您要的是什么。你是想破坏两个记录,还是只破坏检查过的图片?@tadman only picture。您可以理解,因为我正在使用frm(即图片字段)变量生成check_boxSure,但您在问题“Bicycle-仍然存在”中特别抱怨,好像这是个问题。@tadman,Bicycle-它是可成像类型。多态关联请包含控制器的代码。