给出下面的一行代码 routes.rb
map.resources :users
生成的路由可能是这样的:
users GET /users(.:format) {:controller=>"users", :action=>"index"} POST /users(.:format) {:controller=>"users", :action=>"create"} new_user GET /users/new(.:format) {:controller=>"users", :action=>"new"} edit_user GET /users/:id/edit(.:format) {:controller=>"users", :action=>"edit"} user GET /users/:id(.:format) {:controller=>"users", :action=>"show"} PUT /users/:id(.:format) {:controller=>"users", :action=>"update"} DELETE /users/:id(.:format) {:controller=>"users", :action=>"destroy"}
有没有办法将POST /users
映射的默认HTTP方法更改{:controller=>"users", :action=>"create"}
为用于PUT
替代的HTTP方法?
rake routes
然后生成这样的东西:
users GET /users(.:format) {:controller=>"users", :action=>"index"} PUT /users(.:format) {:controller=>"users", :action=>"create"} new_user GET /users/new(.:format) {:controller=>"users", :action=>"new"} edit_user GET /users/:id/edit(.:format) {:controller=>"users", :action=>"edit"} user GET /users/:id(.:format) {:controller=>"users", :action=>"show"} PUT /users/:id(.:format) {:controller=>"users", :action=>"update"} DELETE /users/:id(.:format) {:controller=>"users", :action=>"destroy"}
我知道这对于RESTful路由是不正确的,我只是想知道是否可以更改这些路由使用的HTTP方法.