small medium large xlarge

Generic-user-small
05 Oct 2010, 02:39
Jamal (4 posts)

On page 169, I manage to get the error down to one, just like it says. Then when I update the line_items_controller_test.rb, two more errors crop up. I am confused as to what is causing it, because the errors mention price= which I didn’t think we dealt with. I’m sure I must have made a mistake along the way, and any help would be greatly appreciated.

P.S. Thanks for the great book

  1) Error:
test_should_create_line_item(LineItemsControllerTest):
NoMethodError: undefined method `price=' for #
    app/models/cart.rb:10:in `add_product'
    app/controllers/line_items_controller.rb:45:in `create'
    /test/functional/line_items_controller_test.rb:21:in `test_should_create_line_item'
    /test/functional/line_items_controller_test.rb:20:in `test_should_create_line_item'

  2) Error:
test_should_create_line_item_via_ajax(LineItemsControllerTest):
NoMethodError: undefined method `price=' for #
    app/models/cart.rb:10:in `add_product'
    app/controllers/line_items_controller.rb:45:in `create'
    /test/functional/line_items_controller_test.rb:50:in `test_should_create_line_item_via_ajax'
    /test/functional/line_items_controller_test.rb:49:in `test_should_create_line_item_via_ajax'

23 tests, 33 assertions, 0 failures, 2 errors
Errors running test:functionals!

Generic-user-small
06 Oct 2010, 01:47
Jamal (4 posts)

I attempted redoing the chapter today, and I got the same error. I hope someone can shed some light on what I did wrong, I would rather not have to go back and redo too much.

Generic-user-small
08 Oct 2010, 01:04
Jamal (4 posts)

I hope this helps, I have found the exact page where things go downhill. When I try to complete 11.4 Iteration F4: Hiding an Empty Cart, my Add to Cart button quits working, and later on I hit the errors described above. Is there a resource to download fully working editions of the depot application by chapter? I am running Mac OS X with rails 3.0.0.rc2 and ruby 1.8.7 (2009-06-08 patchlevel 173) [universal-darwin10.0].

Any advice would be appreciated.

Samr_small_pragsmall
09 Oct 2010, 11:27
Sam Ruby (634 posts)

It would help if you posted the your source to app/models/cart.rb.

Page 23 has the source code links. The individual snapshots are not necessarily aligned based on chapter, and may include the results of some “Playtime” exercises.

In particular, on page 141 there is an exercise to add a price to a line item. Search for Add price to line item on this page if you need help doing that exercise.

Generic-user-small
20 Nov 2010, 01:52
Kabir Mohammed (3 posts)

Same problem here Jamal. Exactly the same! Have you been able to solve it?

Generic-user-small
11 Dec 2010, 22:22
Aaron mcLeod (13 posts)

I haven’t run into this issue myself. Just finishing that chapter now, working on the playtime exercises. Have a look at my github repo if it might help: http://github.com/agmcleod/depot

You must be logged in to comment