Class LineItem
In: app/models/line_item.rb
Parent: ActiveRecord::Base

Line items tie products to orders (and before that, to carts). Because the price of a product may change after an order is placed, the line item contains a copy of the product price at the time it was created.

Methods

Public Class methods

Return a new LineItem given a Product.

[Source]

    # File app/models/line_item.rb, line 12
12:   def self.for_product(product)
13:     item = self.new
14:     item.quantity   = 1
15:     item.product    = product
16:     item.unit_price = product.price
17:     item
18:   end

[Validate]