small medium large xlarge

20 Jul 2010, 20:19
Stuart Gale (6 posts)

Hi all,

After changing the code in the line_items_controller create method (to use the new add_product method on the cart) I tried running the tests, and one failed:

1) Error:
NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.-
    /Users/bishboria/Documents/Programming/Ruby/depot/app/models/cart.rb:9:in `add_product'
    /Users/bishboria/Documents/Programming/Ruby/depot/app/controllers/line_items_controller.rb:47:in `create'

Any ideas how this can be fixed?

Thanks, Stuart

20 Jul 2010, 20:44
Stuart Gale (6 posts)

Embarrassingly, It turns out I’m an idiot and pressed - instead of = in the else condition of the add product method. Changed this and the tests worked.

Thanks, Stuart

You must be logged in to comment