您可以(尽管它是一种误用)使用资源映射而不是资源。
您可以将resource :offers
添加到您的routes.rb。
这会给你这样的路线:
offers POST /offers(.:format) {:action=>"create", :controller=>"offers"}
new_offers GET /offers/new(.:format) {:action=>"new", :controller=>"offers"}
edit_offers GET /offers/edit(.:format) {:action=>"edit", :controller=>"offers"}
GET /offers(.:format) {:action=>"show", :controller=>"offers"}
PUT /offers(.:format) {:action=>"update", :controller=>"offers"}
DELETE /offers(.:format) {:action=>"destroy", :controller=>"offers"}
或者我根本就没有使用标准的编辑映射和添加自己:
resources :offers, :except => [:edit, :update] do
get :edit, :on => :collection
put :update, :on => :collection
end
如果我没记错的话,则以下应该在Rails 2.3.x中工作:
map.resources :offers, :except => [:edit, :update], :collection => { :edit => :get, :update => :put }
我没有这样的环境,所以我c ANNOT目前测试...
你可以发布你的'routes.rb'文件吗?或者至少是“提供”路线 – errorhandler 2011-03-14 21:49:50
fyi如果你这样做,那么你将无法链接到特定的优惠。如果你真的担心人们输入不同的ID,那么你需要在对象上实现权限。或者只是让id不可能猜到并将它们链接到会话。 – 2011-03-14 21:52:03