From 35052ebf9c52316a0d823e9d8382f6f46082e8d4 Mon Sep 17 00:00:00 2001 From: Mathieu Martin Date: Fri, 9 Mar 2012 14:50:11 -0500 Subject: [PATCH] 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. --- lib/paperclip.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/paperclip.rb b/lib/paperclip.rb index 3cbe00aaf..eca4ddc1f 100644 --- a/lib/paperclip.rb +++ b/lib/paperclip.rb @@ -138,7 +138,7 @@ def register_processor(name, processor) 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(:all, :order => 'id').each do |instance| + class_for(klass).find_each do |instance| yield(instance) if instance.send(:"#{name}?") end end