I have a "cart" model, a users cart id is stored in their session.
My routes look like this
map.resources :carts
map.cart "cart", :controller => "carts", :action => "show"
in my show view, i displayed the contents of the cart, and everything was fine. Then i decided i wanted the user to be able to update the quantity of items from the show view, so i added this to the view..
<% form_for @cart do |cart_form| %>
<% end %>
and now i get the following error
undefined method `to_sym' for nil:NilClass
on
<% form_for @cart do |cart_form| %>
Interestingly if i remove
map.cart "cart", :controller => "carts", :action => "show"
from my routes, and specify a cart id in the url, it works, but i do not want to be passing cart ids in the url.
Any idea how to fix this please?
[update]
rake routes looks like this:
carts GET /carts(.:format) {:controller=>"carts", :action=>"index"}
POST /carts(.:format) {:controller=>"carts", :action=>"create"}
new_cart GET /carts/new(.:format) {:controller=>"carts", :action=>"new"}
edit_cart GET /carts/:id/edit(.:format) {:controller=>"carts", :action=>"edit"}
GET /carts/:id(.:format) {:controller=>"carts", :action=>"show"}
PUT /carts/:id(.:format) {:controller=>"carts", :action=>"update"}
DELETE /carts/:id(.:format) {:controller=>"carts", :action=>"destroy"}
cart /cart {:controller=>"carts", :action=>"show"}