rails/rails — pull request #8611 by amolpujari (2012-12-26 05:49:37+00:00)
Title: find_in_groups by_column

gives you records in batches by group_by column

Person.where("age > 21").find_in_groups(:age) do |group, value|
sleep(50) # Make sure it doesn't get too crowded in there!

puts "Found #{group.count} records of age = #{value}"

group.each { |person| person.party_all_night! }
end