diff options
author | Go MAEDA <maeda@farend.jp> | 2018-10-06 16:03:26 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2018-10-06 16:03:26 +0000 |
commit | e159928e6b81c02001411e7e886208533178c0ba (patch) | |
tree | 41c78911f17078c798e5fdc1362b7c18aff138d2 /app/models/attachment.rb | |
parent | 323ef3182bc45184c7a14e3a8dc7244850baabed (diff) | |
download | redmine-e159928e6b81c02001411e7e886208533178c0ba.tar.gz redmine-e159928e6b81c02001411e7e886208533178c0ba.zip |
Use find_by instead of where.first to remove unnecessary sorting (#26747).
Patch by Yuichi HARADA.
git-svn-id: http://svn.redmine.org/redmine/trunk@17586 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/attachment.rb')
-rw-r--r-- | app/models/attachment.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 6795f602e..cc9b5f930 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -276,7 +276,7 @@ class Attachment < ActiveRecord::Base def self.find_by_token(token) if token.to_s =~ /^(\d+)\.([0-9a-f]+)$/ attachment_id, attachment_digest = $1, $2 - attachment = Attachment.where(:id => attachment_id, :digest => attachment_digest).first + attachment = Attachment.find_by(:id => attachment_id, :digest => attachment_digest) if attachment && attachment.container.nil? attachment end |