Permalink
Browse files

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.
  • Loading branch information...
1 parent 0c1e812 commit 35052ebf9c52316a0d823e9d8382f6f46082e8d4 @webmat webmat committed with Sporky023 Mar 9, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 lib/paperclip.rb
View
@@ -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

0 comments on commit 35052eb

Please sign in to comment.