Flowdock
find_each(options = {}) public

Yields each record that was found by the find options. The find is performed by find_in_batches with a batch size of 1000 (or as specified by the :batch_size option).

Example:

Person.where("age > 21").find_each do |person|
  person.party_all_night!
end

Note: This method is only intended to use for batch processing of large amounts of records that wouldn’t fit in memory all at once. If you just need to loop over less than 1000 records, it’s probably better just to use the regular find methods.

Show source
Register or log in to add new notes.