09 Nov 2010, 05:53

Micah Alcorn (4 posts)

I am getting this error when I submit line_items to my cart on page 126. All of my test are flawless, and I have effectively copied and pasted the controller and model files from the source code to ensure that I don’t have any typographical errors. Any ideas what might be the problem?

Started POST “/line_items?product_id=product” for at 2010-11-08 23:45:36 -0600 Processing by LineItemsController#create as HTML Parameters: {“authenticity_token”=>”YMDTL4x+fBtxjeZAJS0QKh9qyXeT61p5NyVKHEiLWjk=”, “product_id”=>”product”} SQL (0.5ms) INSERT INTO “carts” (“created_at”, “updated_at”) VALUES (‘2010-11-09 05:45:36.157760’, ‘2010-11-09 05:45:36.157760’) Product Load (0.2ms) SELECT “products”.* FROM “products” WHERE (“products”.”id” = 0) ORDER BY title LIMIT 1 Completed in 232ms

ActiveRecord::RecordNotFound (Couldn’t find Product with ID=product): app/controllers/line_items_controller.rb:52:in `create’

Rendered /home/micahalcorn/.rvm/gems/ruby-1.9.2-rc1/gems/actionpack-3.0.0/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.9ms) Rendered /home/micahalcorn/.rvm/gems/ruby-1.9.2-rc1/gems/actionpack-3.0.0/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (7.9ms) Rendered /home/micahalcorn/.rvm/gems/ruby-1.9.2-rc1/gems/actionpack-3.0.0/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (17.9ms)

09 Nov 2010, 20:14

Yasuo Honda (4 posts)


I’ve met a similar issue with yours as I posted at following url. It looks similar that there is no record in products table where id = 0.


but I have no more information/solution for my issue.

12 Nov 2010, 02:27

Micah Alcorn (4 posts)

I corrected my versions of both ruby and rails to match the book, and I am still getting the same error. Any suggestions?

20 Jan 2011, 03:45

Ellie-cust support (2 posts)


I’m getting the same error, and I’m not enough of a Rails expert yet to understand the problem. Can anyone help?

This is in the latest edition of the book, in “Building the Applicaiton > Task D: Cart Creation”. Thanks.

EDIT Fixed the problem.

I had foolishly written ~~~ :product_id => :product ~~~ when creating my “Add to Cart” button. I shouldn’t have put the colon (:) before “product”

So it should have read: ~~~ :product_id => product ~~~

This is in /depot/app/views/store/index.html.erb on line 14.

  You must be logged in to comment