14 Jan 2013, 16:12
Generic-user-small

Munirah (1 post)

Good day,

I am new to Ruby on Rails and I am reading The Agile book. I am just working through the tutorial but got stuck on chapter 10.

I got this error each time I tried to add an item from the Catalogue

Could not find table ‘line_items’

app/models/cart.rb:6:in `add_product’
app/controllers/line_items_controller.rb:46:in `create’

The code in the first one is
current_item = line_items.find_by_product_id(product_id)

The code in the second is
@line_item = @cart.add_product(product.id)

Can someone kindly help me to understand what I am supposed to be doing. I am really just following the tutorial hoping I will understand as I go along..

Thanks…

28 Jan 2013, 03:07
Generic-user-small

Adrian Lee Elder (9 posts)

Do you have the relationship built between the tables?

product.rb:

has_many :line_items
before_destroy :ensure_not_referenced_by_any_line_item

line_item.rb

belongs_to :product
belongs_to :cart

  You must be logged in to comment