small medium large xlarge

02 Aug 2011, 12:47
Thomas Miskiewicz (2 posts)

Hi there,

I’m working on Chapter 9 and after completing what in the chapter the server says:

NoMethodError in LineItemsController#create

undefined method `line_items’ for 5:Fixnum Rails.root: /home/Thomas Miskiewicz/depot

Application Trace | Framework Trace | Full Trace app/controllers/line_items_controller.rb:53:in `create’ Request


{“product_id”=>”4”, “authenticity_token”=>”dR4nL5zI+R7qIIPwNkl3EoaI1KyFWRokvh92m3PwD8o=”} Show session dump

Show env dump




It looks like this line: @line_item = => product)

is failing.

I was trying hard to find the issue, but I can’t. Can you help?

Thanks Thomas

06 Sep 2011, 17:05
Alexander Ambrose (2 posts)

Thomas, I actually just hit that snag as I was running through this on my lunch break. It’s the line above that. It’s complaining NoMethod on line_items because @cart is nil. The code in the application controller is not running. You can note this by putting in a logging statement in the code and none of it will run.

I don’t have time to debug further myself, but most likely when I’m doing laundry tonight unless someone solves beforehand or you happened to solve it – If you did, please post. =]

22 Sep 2011, 06:56
Alexander Ambrose (2 posts)

Thomas, not sure if you are still watching this or not: My mistake, a simple ‘@’… I had: ` @cart = @current_cart product = Product.find(params[:product_id]) @line_item = product) ` Where I needed: ` @cart = current_cart product = Product.find(params[:product_id]) @line_item = product) `

Notice the @ is not on current_cart. It shouldn’t be there on your method either.

Can’t believe I got hung up on that for hours and then easily find it weeks later at 3 A.M.

You must be logged in to comment