23 Jan 2013, 15:48
Generic-user-small

Adam Tait (8 posts)

I am at the end of Task F: Add a dash of Ajax, and all works as expected until I disable the browsers js capabilities and add something to the cart, when I get:

undefined method `quantity' for nil:NilClass

in app/views/line_items/_line_item.html.erb

Extracted source:

3: <% else %>
4:   <tr>
5: <% end %>
6: 	<td><%= line_item.quantity %>&times;</td>
7: 	<td><%= line_item.product.name %></td>
8: 	<td class="item_price"><%= number_to_currency(line_item.total_price, unit: "&pound;") %></td>
9: </tr>

There is a note:

Trace of template inclusion: app/views/carts/_cart.html.erb, app/views/layouts/application.html.erb

Can somebody point me in the right direction as to how to debug this and get the app working with js disabled?

Thanks

24 Jan 2013, 09:29
Generic-user-small

Adam Tait (8 posts)

Problem solved. It’s amazing what difficulties you can cause yourself with a small typo…

in _line_items.html.erb I had:

<% if line_item = @current_item %>

instead of:

<% if line_item == @current_item %>

Hours it took to find. Absolutely, bloomin’ HOURS. So if you get this problem, above is your solution.

Would love to hear from anybody who could enlighten me on to how to track down these sorts of problems more efficiently/effectively rather than hunting through every line of code.

Cheers

  You must be logged in to comment