I am following the Depot tutorial in Agile Web Development with Rail,
I am getting the following error,
NoMethodError in StoreController#empty_cart
undefined method `empty!' for #<Cart:0x5012250>
Here is my call in store_controller.rb,
def empty_cart
find_cart.empty!
flash[:notice] = 'Your cart is now empty'
redirect_to(:action => 'index')
end
And in my Model cart.rb,
def empty!
@items =
@total_price = 0.0
end
It looks like you might have the empty! method after the private declaration. If so, it will not be visible to other objects.
I always name all the private methods with an underscore in the beginning. Just by looking at the code I know which methods are private and will catch this kind of errors quickly.
Well here is a direct copy,
From store_controller.rb:
Never mind this morning when i started up firefox the error just isn't
there anymore, very strange.