small medium large xlarge

Generic-user-small
07 Dec 2008, 17:49
Roy Stannard (10 posts)

I’m stuck at Chapter 8 too, and in 8.3 but with different error meesage:

NoMethodError in Store#index

Showing app/views/store/_cart.html.erb where line #3 raised:

You have a nil object when you didn’t expect it! The error occurred while evaluating nil.items

Extracted source (around line #3):

1: <div class="cart-title">Your Cart</div> 2: <table> 3: <%= render(:partial => “cart_item”, :collection => cart.items) %>
4:
5: <tr class="total-line"> 6: <td colspan="2">Total</td>

I’ve checked the files without seeing any error.

One point that might be relevant, I’m running Rails 2.2.2

Thanks in advance for any help.

Generic-user-small
18 Feb 2009, 21:03
Greg Lincoln (1 post)

I think your line 3 should look like this: ` <%= render(:partial => “cart_item”, :collection => @cart.items) %> ` (@cart is an instance variable)

You must be logged in to comment