activerecordruby-on-rails-2

Are there any alternative ways for find_each method?


I have been using Rails 2.3.5.
I would like to use find_each method, but it is not in the version.

Are there any alternative ways to use find_each method for Active Record?


Solution

  • Try using find_in_batches:

    Model.find_in_batches(:batch_size => 1000)  do |records|
        records.each { |record| <your logic here> }
    end