Patch #37687 » 0001-Get-attachments-with-single-query-when-rendering-a-j.patch
| app/models/journal.rb | ||
|---|---|---|
|
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
|
||