How do I sum up records within Rails 3?
问题 I have an ItemsSold model which has the total number of magazines, books, videos, greeting_cards, pens sold for a single day. How do I elegantly return an array with the weekly sold totals for each item for the last arbitrary number of weeks? I have a model file: #items_sold.rb class ItemsSold < ActiveRecord::Base attr_accessible :magazines, :books, :videos, :greeting_cards, :pens, :sold_date end My table is defined as follows: t.integer :magazines t.integer :books t.integer :videos t.integer