instance method find_each

Ruby on Rails 2.3.18

Since v2.3.18 Last seen in v2.3.18

Signature

find_each(options = {})

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.find_each(:conditions => "age > 21") 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.

Parameters

options opt = {}
Source
# File activerecord/lib/active_record/batches.rb, line 24
      def find_each(options = {})
        find_in_batches(options) do |records|
          records.each { |record| yield record }
        end

        self
      end

Defined in activerecord/lib/active_record/batches.rb line 24 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::Batches::ClassMethods

Type at least 2 characters to search.

↑↓ navigate · open · esc close