routes in rails - removing actions when setting up a resource

孤人 提交于 2019-12-03 10:37:28

问题


I've setup a simple app and added a scaffold to do some of the work for me (I'm a noob).

  resources :cars

How do I remove certain actions from the routes? And remove the corresponding urls?

For example I want to keep the 'show' and 'edit' actions & urls.

But I don't want there to be a 'new' 'index' or 'delete'

I understand this is probably a really simple question, but I've not been able to find an answer.


回答1:


resources :cars, :except => [:new, :index, :delete]

or

resources :cars, :only => [:show, :edit]

Also take a look at Rails Guides



来源:https://stackoverflow.com/questions/8258392/routes-in-rails-removing-actions-when-setting-up-a-resource

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!