small medium large xlarge

Generic-user-small
06 Apr 2010, 02:36
Will D (2 posts)

After completing the coding (which I have rechecked many times) for the Checkout Forms on 143-145, upon clicking the checkout button I received the following error. The Store page works fine, it adds items to the Cart, Empty Cart works fine, the following only occurs when I click Checkout. Any thoughts?

NoMethodError in Store#checkout

Showing app/views/layouts/store.html.erb where line #19 raised:

undefined method `items’ for nil:NilClass

Extracted source (around line #19):

16: <div id="columns"> 17: <div id="side"> 18: <div id="cart"> 19: <% hidden_div_if(@cart.items.empty?, :id => “cart”) do %> 20: <%= render(:partial => “cart”, :object => @cart) %> 21: <% end %> 22: </div>

Generic-user-small
06 Apr 2010, 20:22
Ivan Holsbach Schuster (4 posts)

undefined method `items’ for nil:NilClass

It seems that variable @cart is nil.

Generic-user-small
06 Apr 2010, 22:31
Will D (2 posts)

Well I fixed something and then figured out I misentered “find_cart” as find.cart - hence the missing method. Thanks for your help, I focused my search on cart methods and the store controller which helped a lot.

Generic-user-small
19 Oct 2010, 20:58
Ramoel Rodrigues de Assis (1 post)

I had the same error. To solve it, check if in your StoreController you put the private def find_cart above all others defs.

You must be logged in to comment