Commit 35052ebf by Mathieu Martin Committed by Luke Griffiths

Load models in batches, to make this more practical for large datasets.

Note: find_each doesn't support order because it already specifies it.
And it happens to be 'id' as well.
parent 0c1e812d
...@@ -138,7 +138,7 @@ module Paperclip ...@@ -138,7 +138,7 @@ module Paperclip
def each_instance_with_attachment(klass, name) def each_instance_with_attachment(klass, name)
unscope_method = class_for(klass).respond_to?(:unscoped) ? :unscoped : :with_exclusive_scope unscope_method = class_for(klass).respond_to?(:unscoped) ? :unscoped : :with_exclusive_scope
class_for(klass).send(unscope_method) do class_for(klass).send(unscope_method) do
class_for(klass).find(:all, :order => 'id').each do |instance| class_for(klass).find_each do |instance|
yield(instance) if instance.send(:"#{name}?") yield(instance) if instance.send(:"#{name}?")
end 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