diff options
author | Go MAEDA <maeda@farend.jp> | 2022-09-23 04:47:49 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2022-09-23 04:47:49 +0000 |
commit | d7df1a740ea199e9b2210cc30f86830a9bf28db1 (patch) | |
tree | 2fff1046078bd7d8970aa1a4a9829b0c9d3676e9 | |
parent | 43c7cc03a52d1aedb3e59d13a6afff3554de41a5 (diff) | |
download | redmine-d7df1a740ea199e9b2210cc30f86830a9bf28db1.tar.gz redmine-d7df1a740ea199e9b2210cc30f86830a9bf28db1.zip |
Unify duplicate codes (#37687).
Patch by Go MAEDA.
git-svn-id: https://svn.redmine.org/redmine/trunk@21832 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/helpers/journals_helper.rb | 3 | ||||
-rw-r--r-- | app/models/journal.rb | 2 |
2 files changed, 2 insertions, 3 deletions
diff --git a/app/helpers/journals_helper.rb b/app/helpers/journals_helper.rb index 18224c196..066226e29 100644 --- a/app/helpers/journals_helper.rb +++ b/app/helpers/journals_helper.rb @@ -21,8 +21,7 @@ module JournalsHelper # Returns the attachments of a journal that are displayed as thumbnails def journal_thumbnail_attachments(journal) - ids = journal.details.select {|d| d.property == 'attachment' && d.value.present?}.map(&:prop_key) - ids.any? ? Attachment.where(:id => ids).select(&:thumbnailable?).sort_by{|a| ids.index(a.id.to_s)} : [] + journal.attachments.select(&:thumbnailable?) end # Returns the action links for an issue journal diff --git a/app/models/journal.rb b/app/models/journal.rb index a4efcdbee..e60295c34 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -143,7 +143,7 @@ class Journal < ActiveRecord::Base def attachments ids = details.select {|d| d.property == 'attachment' && d.value.present?}.map(&:prop_key) - Attachment.where(id: ids).to_a + Attachment.where(id: ids).sort_by {|a| ids.index(a.id.to_s)} end # Returns a string of css classes |