diff options
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 |