mirror of
https://github.com/meineerde/redmine.git
synced 2026-01-31 11:37:14 +00:00
Retrieve attachments with a single query when rendering a journal (#37687).
Patch by Go MAEDA. git-svn-id: https://svn.redmine.org/redmine/trunk@21831 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
40774c2cf4
commit
43c7cc03a5
@ -142,7 +142,8 @@ class Journal < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def attachments
|
||||
details.select{ |d| d.property == 'attachment' }.map{ |d| Attachment.find_by(:id => d.prop_key) }.compact
|
||||
ids = details.select {|d| d.property == 'attachment' && d.value.present?}.map(&:prop_key)
|
||||
Attachment.where(id: ids).to_a
|
||||
end
|
||||
|
||||
# Returns a string of css classes
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user