Agile Web Development with Rails 7: page 171 Falta product en total_price (solved)

En el código de la página 171 pone:

def total_price
    price * quantity
end

Creo que falta product en la función total_price:

def total_price
    product.price * quantity
end

Mira la parte superior de la página 66:

Finally, you might have noticed that we’ve duplicated the product’s price in
the line item data. Here we’re breaking the “initially, keep it simple” rule
slightly, but it’s a transgression based on experience. If the price of a product
changes, that price change shouldn’t be reflected in the line item price of
currently open orders, so each line item needs to reflect the price of the
product at the time the order was made.

Y anteriormente en esta página:

Note that if you didn’t choose to do the optional exercises in Playtime, on page
139, you need to modify all of the references to products and carts at this time.

Tu respuesta funciona, pero hay una mejor respuesta:

cart.rb

Ok, entendido!!!