small medium large xlarge

Generic-user-small
20 Jan 2011, 15:01
Alper Sunar (2 posts)

Hello,

In Iteration G1: Capturing an order on page 171, LineItem model is displayed.

class LineItem < ActiveRecord::Base belongs_to :order belongs_to :product belongs_to :cart def total_price product.price * quantity end end

In Iteration G1: Capturing an order on page 174. We look in the database

depot> sqlite3 -line db/development.sqlite3 SQLite version 3.6.16 Enter “.help” for instructions sqlite> select * from orders; id = 1 name = Dave Thomas address = 123 Main St email = customer@example.com pay_type = Check created_at = 2010-06-09 13:40:40 updated_at = 2010-06-09 13:40:40 sqlite> select * from line_items; id = 10 product_id = 3 cart_id = created_at = 2010-06-09 13:40:40 updated_at = 2010-06-09 13:40:40 quantity = 1 price = 49.5 order_id = 1

My question is: When/how is the price column in line_items table created? I thought price was an attribute of the Product model.

Thanks.

Samr_small_pragsmall
20 Jan 2011, 23:43
Sam Ruby (634 posts)

Playtime in Chapter 10, after iteration E3, on page 142.

Generic-user-small
21 Jan 2011, 20:37
Alper Sunar (2 posts)

Thanks Sam, I missed that. I guess I need to read the playtime sections more carefully.

You must be logged in to comment