From e9b54ad0121e806750feefe2f39a2d2adf28e8a9 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 14 Jan 2016 16:04:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E9=99=84=E4=BB=B6=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=E5=87=8F=E6=8E=89=E5=BE=97=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/attachment.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 3088714ee..2c99b6870 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -90,7 +90,7 @@ class Attachment < ActiveRecord::Base before_save :files_to_final_location,:act_as_course_activity after_create :office_conver, :be_user_score,:act_as_forge_activity,:create_attachment_ealasticsearch_index after_update :office_conver, :be_user_score,:update_attachment_ealasticsearch_index - after_destroy :delete_from_disk,:down_user_score,:delete_attachment_ealasticsearch_index#, :decrease_attchments_count + after_destroy :delete_from_disk,:down_user_score,:delete_attachment_ealasticsearch_index, :decrease_attchments_count # add by nwb # 获取所有可公开的资源文件列表 @@ -641,12 +641,12 @@ class Attachment < ActiveRecord::Base end end - # def decrease_attchments_count - # if self.container_type == "Project" - # count = self.container.attachments_count - # #self.container.update_attribute(:attachments_count, self.container.attachments_count - 1) - # end - # end + def decrease_attchments_count + if self.container_type == "Project" && !self.project.project_score.nil? + aatach_count = self.container.project_score.attach_num - 1+ + self.container.project_score.update_attribute(:attach_num, aatach_count) + end + end end # Delete the previous articles index in Elasticsearch