rails/rails — pull request #4003 by chrisfinne (2011-12-16 16:17:15+00:00)
Title: Allow blocks for count with ActiveRecord::Relation like we do with sum

also added tests and documentation about sum allowing a block.

I've been burned too many times by thinking I'm working with an Array. If we can sum on ActiveRecord::Relations like we do with Arrays, why not count with a block as well?

persons = Person.where(:gender=>'male')
persons.count{|person| false} # should equal 0, but will equal persons.size