问题
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