small medium large xlarge

06 Dec 2014, 18:19
Roelof Wobben (2 posts)


I did everything according to the book except the layout. And when I do the test of the LineItemController I see this error message:

LineItemsControllerTest#test_should_create_line_item: RuntimeError: @controller is nil: make sure you set it in your test’s setup method.

my code can be found here :


20 Sep 2015, 09:43
George A (1 post)

Hey. I know its been a year, but I hope it helps you, or at least someone that might encounter this problem in the future. I had the same issue as you. Someone had a solution to this problem, which can be seen in the following link:

Essentially, the issue is that @controller is not initiated, and the reason behind it is that current_cart.rb does not exist. If you look at page 108, at the top you will see the author shows you what should be inside current_cart.rb. If you were like me, since the author did not instruct us to edit the file, I assumed the file would be made for you. However, you need to make the file and put that content in it, and this is not explained to you in the book unfortunately.

Hopefully this helps!

You must be logged in to comment