small medium large xlarge

Generic-user-small
04 Jul 2009, 06:43
Andrew Kay (3 posts)

So, I have that lovely NoMethodError listed in 8.3 (pg105 in book)…the problem is it’s not resolved by the books instructions (they’re the same as the pdf).

restarting server doesn’t fix it, hosing cookies doesn’t fix it, clearing the sessions db doesn’t fix it. I’m at a loss for what the problem is. My code is the same as the demo code (I’ve gone through line by line and even c&p’d).

ruby 1.8.7p72 rails 2.3.2 mysql 5.1.3

error:

NoMethodError in Store#add_to_cart 
Showing app/views/store/add_to_cart.html.erb where line #4 raised: 

undefined method `quantity' for #<Product:0x4cfe410>

Extracted source (around line #4): 

1: <h2>Your Pragmatic Cart</h2>
2: <ul>
3:   <% for item in @cart.items %>
4:     <li><%= item.quantity %> &times; <%=h item.title %></li>
5:   <% end %>
6: </ul>

</code>

Generic-user-small
04 Jul 2009, 20:28
Andrew Kay (3 posts)

Fixed my issue. While going over my code this morning after I woke up, I noticed my ifelse statement was wrong in cart.rb. For some reason it didn’t save the changes I made when adding

@items << CartItem.new(product)

</code>

Everything else was saved…don’t know why that wasn’t. It’s wondrous what a good nights sleep can do to tired eyes staring at code all day long.

You must be logged in to comment