Create a migration that copies the product price into the line item, and add_product method in the Cart model to capture the price whenever a new line item is created.
Readers’ Solutions blah
Marius saysThe migration first:
rails g migration add_product_price_to_line_item price:decimal
class AddProductPriceToLineItem < ActiveRecord::Migration def self.up add_column :line_items, :price, :decimal, :precision => 8, :scale => 2 end def self.down remove_column :line_items, :price end end
The migration must also copy the product price associated with the line item.