small medium large xlarge

Generic-user-small
09 Oct 2008, 15:46
mdc (1 post)

Hi, I have the beta from June 4th.

When I replaced the previous code with this

<%= render(:partial => "cart_item", :collection => @cart.items) %>

</pre

And do this in the view _cart_item.html.erb


<tr>
	<td><%= cart_item.quantity %>&times;</td>
	<td><%=h cart_item.title %></td>
	<td class="item-price"><%= number_to_currency(cart_item.price) %></td>
</tr>

I get this error:

NoMethodError in Store#add_to_cart

Showing store/_cart_item.html.erb where line #2 raised:

You have a nil object when you didn't expect it!
The error occurred while evaluating nil.quantity
Extracted source (around line #2):

1: <tr>
2: 	<td><%= cart_item.quantity %>&times;</td>
3: 	<td><%=h cart_item.title %></td>
4: 	<td class="item-price"><%= number_to_currency(cart_item.price) %></td>
5: </tr>

I’m not sure why, did anyone get the same error or know what’s wrong?

Squareportrait200_pragsmall
12 Nov 2008, 01:12
Joshua R. Poulson (8 posts)

I thought I was doing well with D1, and then I started getting these errors when I click buttons:

` Unknown action

No action responded to #. Actions: add_to_cart, empty_cart, and index `

Yet the actions seem to happen! I wonder if you and I in similar places where something is a tiny bit off.

Squareportrait200_pragsmall
12 Nov 2008, 03:54
Joshua R. Poulson (8 posts)

I must have had a typo in my app/controllers/store_controller.rb as I reloaded it from the source site and it all works now.

You must be logged in to comment