From a85a3339bbf2f2af474cbd49896156415e1f132f Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Wed, 30 Dec 2015 18:24:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9A=84=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E9=99=90=E5=88=B6=E5=8A=A0=E5=A4=A7=20=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=9C=89=E4=BA=86=E5=8E=86=E5=8F=B2=E7=89=88?= =?UTF-8?q?=E6=9C=AC=20=E6=95=B0=E6=8D=AE=E8=AE=B0=E5=BD=95=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E8=A2=AB=E5=88=A0=E9=99=A4=20=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E8=A2=AB=E5=8F=91=E9=80=81=E8=BF=87=EF=BC=8C?= =?UTF-8?q?=E6=88=96=E8=80=85=E6=9C=89=E4=BA=86=E5=8E=86=E5=8F=B2=E7=89=88?= =?UTF-8?q?=E6=9C=AC=EF=BC=8C=E7=A1=AC=E7=9B=98=E4=B8=8A=E7=9A=84=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=92=8C=E6=95=B0=E6=8D=AE=E8=AE=B0=E5=BD=95=E5=B0=B1?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E8=A2=AB=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/attachment.rb | 3 ++- app/views/users/_resources_list.html.erb | 2 +- app/views/users/user_resource.html.erb | 9 +++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/models/attachment.rb b/app/models/attachment.rb index b6253de7a..4809bc643 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -355,8 +355,9 @@ class Attachment < ActiveRecord::Base end end + #有了历史记录的数据记录是不能被删除的。 def destroyable - Attachment.where("disk_filename = ? AND id <> ?", disk_filename, id).empty? && self.attachment_histories.count == 0 && Attachment.where('copy_from = ?',self.id) .count == 0 + Attachment.where("disk_filename = ? AND id <> ?", disk_filename, id).empty? && self.attachment_histories.count == 0 end # Returns file's location on disk diff --git a/app/views/users/_resources_list.html.erb b/app/views/users/_resources_list.html.erb index ef6397ec0..621efc902 100644 --- a/app/views/users/_resources_list.html.erb +++ b/app/views/users/_resources_list.html.erb @@ -7,7 +7,7 @@ <% attachments.each do |attach| %>