What am I doing wrong with find_in_batches?

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 })


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



Thanks for any help!

Looks like you're missing the "id" in your :select, which
#find_in_batches relies upon. Try:

:select => "distinct(email), id"

Perfect! Thanks Erol. I knew it was something very basic.