I'm using rails to try and calculate the total of a specific column in my database. I'm using this at the moment:
@total = Product.sum (:cost)
Which works and returns the combined cost of everything in the table. What about if I'm trying to do that from data which is already in an array? For example:
@products = Product.where('date >= ? AND date <= ?', Date.today.beginning_of_month.to_datetime, Date.today.end_of_month.end_of_day.to_datetime)
Can you then do the same thing on that array of products?
Hope someone can help! Ta.