解决资源总数为负数的问题

This commit is contained in:
huang 2016-02-23 13:02:37 +08:00
parent 0b34be5a30
commit 44f192e5a6
1 changed files with 7 additions and 2 deletions

View File

@ -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