09 Oct 2008, 15:46
Generic-user-small

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) %>

And do this in the view _cart_item.html.erb

<code>
<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>
</code>

I get this error:

<code>
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>
</code>

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

12 Nov 2008, 01:12
Squareportrait200_pragsmall

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 #<Cart:0x11fb2e0>. 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.

12 Nov 2008, 03:54
Squareportrait200_pragsmall

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