Hello,
I posted this incorrectly on the ruby forum (forgot that it involves ActiveRecord, so it's rails).
I wonder how you step down through an association to do a sum. If I have the following associations
user has_many carts cart has_many cart_items cart_item has_one item
I'd like to do a sum of the unit price of all items in the cart and tried the following
current_user.carts.first.cart_items.items.sum(:unit_price) current_user.carts.first.cart_items.sum(:item.unit_price)
Neither worked.
TIA
GP