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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment