]> source.dussan.org Git - redmine.git/commitdiff
Use journalized attachments to prevent a query when displaying added file.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 24 Jan 2015 10:25:05 +0000 (10:25 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 24 Jan 2015 10:25:05 +0000 (10:25 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@13937 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/issues_helper.rb

index a112d76afd4583fa601b460acb8ea33935a316b2..c16ce5022deb78033044adddb1b4091bd8933f12 100644 (file)
@@ -356,7 +356,8 @@ module IssuesHelper
       if detail.old_value && detail.value.blank? && detail.property != 'relation'
         old_value = content_tag("del", old_value)
       end
-      if detail.property == 'attachment' && !value.blank? && atta = Attachment.find_by_id(detail.prop_key)
+      if detail.property == 'attachment' && value.present? &&
+          atta = detail.journal.journalized.attachments.detect {|a| a.id == detail.prop_key.to_i}
         # Link to the attachment if it has not been removed
         value = link_to_attachment(atta, :download => true, :only_path => options[:only_path])
         if options[:only_path] != false && atta.is_text?