Hey guys,
im very very stuck trying to figure out how to go about implementing a sum method to sum up the points a user gained for each day of the week.
schema: create_table "user_point_logs", :force => true do |t| t.column "user_id", :integer t.column "points", :integer t.column "created_at", :datetime end
I want to be about to simply calculate the total points the user gained for the last seven days.
I got this so far. controller: @statistics = @current_user.user_point_logs.find(:all, :conditions => ['created_at > ?', 7.days.ago])
view: @statistics.sum(&:points)
can any provided me some snippets to help me out?
regards,
Chubbs