# NoMethodError in Store#add\_to\_cart

**URL:** <https://www.ruby-forum.com/t/nomethoderror-in-store-add-to-cart/114878>\
**Category:** Ruby-Forum\
**Created:** [September 18, 2007, 2:07pm UTC](https://www.ruby-forum.com/t/nomethoderror-in-store-add-to-cart/114878 "2007-09-18T14:07:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![crispy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e47774/32.png) [@crispy](https://www.ruby-forum.com/u/crispy)\
**Post date:** [September 18, 2007, 2:07pm UTC](https://www.ruby-forum.com/t/nomethoderror-in-store-add-to-cart/114878/1 "2007-09-18T14:07:54Z")

</div>

Hello - I am new to not only Ruby but programing in general. I have  
been given this book “Agile Web D. with Rails” and told that it  
will tell me everything I need to know. I am completely lost. I have  
managed to get to page 99, but I have been stuck with this error for  
days and since I have no knowledge of programing I don’t know what to do  
from here. Can someone please help me.

NoMethodError in Store#add\_to\_cart

Showing app/views/store/add\_to\_cart.rhtml where line #4 raised:

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

Extracted source (around line #4):

1:

# Your Pragmatic Cart
  
2:  
3: 
  
4: \<% for cart\_item in @cart.items %\>  
5: - \<%= h(item.title) %\>
  
6: \<% end %\>  
7: 

Any help would be greatly appreciated. I am sure this is a pretty  
stupid question, but I have no clue what else to do but ask it!

crispy
