diff --git a/app/models/issue.rb b/app/models/issue.rb index d526b5102..6325a327f 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -231,7 +231,7 @@ class Issue < ApplicationRecord att_ids += self.description.to_s.scan(/\/api\/attachments\/.+\"/).map{|s|s.match(/\d+/)[0]} att_ids += self.description.to_s.scan(/\/api\/attachments\/\d+/).map{|s|s.match(/\d+/)[0]} if att_ids.present? - Attachment.where(id: att_ids).where(container_type: nil).update_all(container_id: self.id, container_type: self.class.name) + Attachment.where(id: att_ids).where("container_type IS NULL OR container_type = 'Issue'").update_all(container_id: self.project_id, container_type: "Project") end end diff --git a/app/models/journal.rb b/app/models/journal.rb index 3229ae886..30cd94143 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -67,7 +67,7 @@ class Journal < ApplicationRecord att_ids += self.notes.to_s.scan(/\/api\/attachments\/.+\"/).map{|s|s.match(/\d+/)[0]} att_ids += self.notes.to_s.scan(/\/api\/attachments\/\d+/).map{|s|s.match(/\d+/)[0]} if att_ids.present? - Attachment.where(id: att_ids).where(container_type: nil).update_all(container_id: self.id, container_type: self.class.name) + Attachment.where(id: att_ids).where("container_type IS NULL OR container_type = 'Journal'").update_all(container_id: self.issue.project_id, container_type: "Project") end end