I have two models of concern, "Order" and "Kit"; each order has_one :kit
Each "Kit" has a 'cost' value. Within a controller I want to be able to sum together the costs for each 'order'.
Logically I thought this would make sense (but it doesn't work):
@revenue = Order.Kit.sum(:cost)
Any help would be appreciated. Thanks.
Example:
A user creates a new order for a kit which has cost of 20. I would like the @revenue to be of hence value 20 (reflecting 'sales'). When someone else creates a new order for the same kit, @revenue should change to 40.