Created
June 9, 2013 21:39
Revisions
-
alexbartlow created this gist
Jun 9, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ class Message < ActiveRecord::Base scope :last_two_weeks, -> { where(:created_at => (2.weeks.ago..Time.now)) } scope :for_month, (date) -> { where(:created_at => (date.beginning_of_month..date.end_of_month)) } def self.sum_word_count sum(:word_count) end end dan.messages.for_month(2.months.ago).sum_word_count dan.messages.last_two_weeks.sum_word_count dan.messages.sum_word_count