Rails 资源单数还是复数?
我有一条搜索路线,我想将其设为单数,但是当我指定单数路线时,它仍然会生成复数控制器路线,这是应该的样子吗?
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"}
复数控制器“搜索”
我实际上只有一条路线......创建搜索:
所以我做了:match“search”=> “search#create”
我只是想知道将来我是否仍然应该保留控制器复数?铁轨3.0.9
I have a search route which I would like to make singular but when I specify a singular route it still makes plural controller routes, is this how it's supposed to be?
resource :search
Gives me
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"}
Plural controller "searches"
I only have one route really... to create a search:
So I did: match "search" => "search#create"
I'm just wondering for the future if I'm still supposed to keep the controller plural? Rails 3.0.9
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(4)
~没有更多了~
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
是的,事情就应该这样。引用 Rails 路由指南:
http://edgeguides.rubyonrails.org/routing.html#singular-resources
Yes, that's how it's supposed to be. Quote from the Rails Guide on Routing:
http://edgeguides.rubyonrails.org/routing.html#singular-resources