]> source.dussan.org Git - redmine.git/commitdiff
Code cleanup.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 25 May 2012 20:51:43 +0000 (20:51 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 25 May 2012 20:51:43 +0000 (20:51 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9716 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/attachment.rb

index 1eb6dc37a2fc7c5c3c0a082cbe0f210b579d78cc..8daa4cf0b3917396097cb9a0d1b371957155da18 100644 (file)
@@ -175,7 +175,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.first(:conditions => {:id => attachment_id, :digest => attachment_digest})
+      attachment = Attachment.where(:id => attachment_id, :digest => attachment_digest).first
       if attachment && attachment.container.nil?
         attachment
       end
@@ -200,8 +200,7 @@ class Attachment < ActiveRecord::Base
   end
 
   def self.prune(age=1.day)
-    attachments = Attachment.all(:conditions => ["created_on < ? AND (container_type IS NULL OR container_type = '')", Time.now - age])
-    attachments.each(&:destroy)
+    Attachment.where("created_on < ? AND (container_type IS NULL OR container_type = '')", Time.now - age).destroy_all
   end
 
   private