app/models/cart.rb
# cart has many orders but order belongs to cart
cart has many orders but order belongs to cart
cart has many orders but order belongs to cart
def subtotal_cart
        sum = 0
        self.cart_products.each { |p| sum+= p.total_price }
        return sum 
    end
def subtotal_cart sum = 0 self . cart_products . each { | p | sum += p . total_price } return sum end
cart has many orders but order belongs to cart
cart has many orders but order belongs to cart