thoughtbot/paperclip — pull request #777 by webmat (2012-03-09 20:36:16+00:00)
Title: This makes the refresh:* rake tasks quite a bit faster for big datasets

Hey guys,

One of my models has a over 500 000 rows in the database. Running the refresh tasks on these didn't work, since the tasks did a find(:all). So I refactored ```Paperclip.each_instance_with_attachment``` a little.

- I use Rails' find_each, which loads models in batches
- I've also moved the condition to detect whether the record has an attachment to the finder.

You'll notice that the order by id isn't there anymore. AR::find_each raises an exception if you supply an order, because it wants to specify one itself. It orders by id :-) So that behaviour is preserved.

I hope you think this pull request is valuable!

Thanks for Paperclip, it's made my dealings with attachments a breeze for years :-)

Cheers