Put SUM in attribute using ActiveRecord
My Question is simple:

I have a `Lot` table with columns: `(id, product_id, quantity)`


I want to create one scope that group all registers by product_id and calculates `sum` 
of quantity column and return results on Array of Lot Objects.

I need this:

    lots = Lot.sum_lots
    lots.each do |lot|
      puts lot.product.name + " : " + lot.quantity.to_s
    end

Thank you!
Put SUM in attribute using ActiveRecord
===

My Question is simple:

I have a `Lot` table with columns: `(id, product_id, quantity)`


I want to create one scope that group all registers by product_id and calculates `sum` 
of quantity column and return results on Array of Lot Objects.

I need this:

    lots = Lot.sum_lots
    lots.each do |lot|
      puts lot.product.name + " : " + lot.quantity.to_s
    end

Thank you!