From 44f192e5a65772099219f0c27633347d30fdea2d Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 23 Feb 2016 13:02:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=B5=84=E6=BA=90=E6=80=BB?= =?UTF-8?q?=E6=95=B0=E4=B8=BA=E8=B4=9F=E6=95=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/attachment.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/models/attachment.rb b/app/models/attachment.rb index ea9ad2cc0..0bbbd9a54 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -643,8 +643,13 @@ class Attachment < ActiveRecord::Base 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) + attach_count = self.container.project_score.attach_num - 1 + if attach_count < 0 + self.container.project_score.update_attribute(:attach_num, 0) + else + self.container.project_score.update_attribute(:attach_num, attach_count) + end + end end end