Commit 32199e21 by Mathieu Martin Committed by Luke Griffiths

Make this yet dramatically faster when a lot of the models don't have attachments

parent 35052ebf
......@@ -138,8 +138,8 @@ module Paperclip
def each_instance_with_attachment(klass, name)
unscope_method = class_for(klass).respond_to?(:unscoped) ? :unscoped : :with_exclusive_scope
class_for(klass).send(unscope_method) do
class_for(klass).find_each do |instance|
yield(instance) if instance.send(:"#{name}?")
class_for(klass).find_each(:conditions => "#{name}_file_name is not null") do |instance|
yield(instance)
end
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment