Rails 2.3 has this feature. You can specify the batch_size parameter.
User.find_in_batches(:batch_size =>25) do |group|
You can find a good tutorial here . Please note that Rails will issue a request for every 25 entries. This is useful for maintaining low memory if you process a large number of records. If you want to split the results into multiple arrays, you can use in_groups_of , as suggested by Matt.
source share