Search Results

Search found 1 results on 1 pages for 'butterywombat'.

Page 1/1 | 1 

  • rails summing column values of rows with similar attributes

    - by butterywombat
    Hi all, I have a Sites table that has columns name, and time. The name does not have to be unique. So for example I may have the entries 'hi.com, 5', 'hi.com, 10', 'bye.com, 4'. I would like to sum up all the unique sites so that i get 'hi.com, 15' and 'bye.com, 4' for plotting purposes. How can I do that? (For some reference I was looking at http://railscasts.com/episodes/223-charts but I couldn't get the following (translated to my table) to work def self.total_on(date) where("date(purchased_at) = ?", date).sum(:total_price) end nor do I really understand the syntax of the 'where("date(purchased_at) = ?", date)' part. Thanks for helping a rails newbie!

    Read the article

1