Restful cart routing problems

I want to have a cart with urls like this

it “should map { :controller => ‘cart’, :action => ‘index’ } to /cart”
do
route_for(:controller => “cart”, :action => “index”).should ==
“/cart”
end

it “should map { :controller => ‘cart’, :action => ‘show’, :id => 1 }
to
/cart/1” do
route_for(:controller => “cart”, :action => “show”, :id => 1).should

“/cart/1”
end

it “should map { :controller => ‘cart’, :action => ‘edit’,:id => 1} to
/cart/1/edit” do
route_for(:controller => “cart”, :action => “edit”,:id => 1).should

“/cart/1/edit”
end

it “should map { :controller => ‘cart’, :action => ‘update’,:id => 1 }
to
/cart/1” do
route_for(:controller => “cart”, :action => “update”,:id =>
1).should ==
“/cart/1”
end

it “should map { :controller => ‘cart’, :action => ‘destroy’,:id => 1}
to
/cart/1” do
route_for(:controller => “cart”, :action => “destroy”,:id =>
1).should
== “/cart/1”
end

That is, I want cart to act like a plural resource mapping for the
singular
cart_items but I don’t know how to do this

map.resources :carts would give me urls like /carts/1

I tried to map it the long way
map.with_options(:controller => “cart”) do |m|
m.cart_url “/cart”,:action => “index”,:method => :get
m.formatted_cart_url “/cart.:format”,:action => “index”,:method =>
:get
m.cart_item “/cart/:id”, :action => “show”, :method => :get
m.connect “/cart/:id”, :action => “update”, :method => :put
m.connect “/cart/:id”, :action => “destroy”, :method => :delete
end

but this didn’t pass the above specification

What would be the best way to map this so I get the urls like above

Thanks,

dom

I

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs