diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-11-24 05:31:29 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-11-24 05:31:29 +0000 |
commit | 564321b2d5b84a3b7d45b804c932790f8c6acac5 (patch) | |
tree | 606b818ba2d0f2017abd300b60304888a44611ce /app/models/attachment.rb | |
parent | 627dfd80b6371a44bdfa6825aa1ed0078a0f1dde (diff) | |
download | redmine-564321b2d5b84a3b7d45b804c932790f8c6acac5.tar.gz redmine-564321b2d5b84a3b7d45b804c932790f8c6acac5.zip |
move logic to use latest image file attachment to class method for common use (#3261)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7908 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/attachment.rb')
-rw-r--r-- | app/models/attachment.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/app/models/attachment.rb b/app/models/attachment.rb index c5a5187d1..2dda3f353 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -167,6 +167,12 @@ class Attachment < ActiveRecord::Base {:files => attached, :unsaved => obj.unsaved_attachments} end + def self.latest_attach(attachments, filename) + attachments.sort_by(&:created_on).reverse.detect { + |att| att.filename.downcase == filename.downcase + } + end + private def sanitize_filename(value) # get only the filename, not the whole path |