我有一条搜索路线,我想将其设为单数,但当我指定单数路线时,它仍然会生成复数 Controller 路线,这是应该的样子吗?
resource :search
给我
search POST /search(.:format) {:action=>"create", :controller=>"searches"}
new_search GET /search/new(.:format) {:action=>"new", :controller=>"searches"}
edit_search GET /search/edit(.:format) {:action=>"edit", :controller=>"searches"}
GET /search(.:format) {:action=>"show", :controller=>"searches"}
PUT /search(.:format) {:action=>"update", :controller=>"searches"}
DELETE /search(.:format) {:action=>"destroy", :controller=>"searches"}
复数 Controller “搜索”
我实际上只有一条路线......来创建搜索:
所以我这样做了:匹配“search”=>“search#create”
我只是想知道 future 我是否仍然应该保留 Controller 复数? Rails 3.0.9
最佳答案
是的,事情就应该这样。引用 Rails 路由指南:
Because you might want to use the same controller for a singular route (/account) and a plural route (/accounts/45), singular resources map to plural controllers.
http://edgeguides.rubyonrails.org/routing.html#singular-resources
关于ruby-on-rails - Rails 资源单数还是复数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6939688/