Feeds:
Posts
Comments

Archive for the ‘Ruby on Rails’ Category

I wanted to iterate over an active record in batches. Found a great example but for my needs I wanted to walk backwards over the batch.

Needless to say it’s not possible. I don’t mind find_each limited to the id field, but DESC would be nice.

model.find_each(:batch_size => 200, :order => "DESC") do |instance|
  puts instance.inspect
end
# => You can't specify an order, it's forced to be model.id ASC
Advertisements

Read Full Post »

%d bloggers like this: