解决资源总数为负数的问题
This commit is contained in:
parent
0b34be5a30
commit
44f192e5a6
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue