I'm testing out ActiveRecord's find_in_batches and I'm missing something very basic I think. I can only get it to return the values from the first chunk (batch_size) and nothing more...how do I get it to process chunks until there are no more?
the same number as the standard count method? I mean, shouldn't these be equivalent?
Entry.count(:select => "distinct(email)", :conditions => { :opt_in => true, :blacklist => false })
313954
count = 0 Entry.find_in_batches(:batch_size => 2000, :select => "distinct(email)", :conditions => { :opt_in => true, :blacklist => false} ) do |entries| entries.each { count += 1 } puts count end
2000
Thanks for any help!