2014/11/21
Let the database do all of the heavy lifting for counting your ActiveRecord objects.
Record.pluck(:owner_id).each_with_object(Hash.new(0)) { |id, counts|
counts[id] += 1
}
Sums up the number of records for a owner in Ruby. The same can be achieved via ActiveRecord.
Record.group(:owner_id).count