Removing a route
Since I used scaffolding to create my Deposit model,
resources :deposits
generates a bunch of routes. i want to be able to delete some of those routes for particular models. For example I do not want a "deposts/23/edit" route. I know I can do a redirect in the controller or do a
match "deposits/:id/edit", :to => "deposit#new"
which just shows the new deposit page but does not change the url on the browser.
is there a way to completely remove a certain action through declaring something开发者_如何学运维 in the rails routes.rb file. so that particular actions are just not accessible.
I reccomend looking over the Ruby on Rails Guide for Routing it discuses important core concepts and presents you with some good information on how routes are wired the way they are.
If you still wish to remove the edit route you will find a useful part of the guide here the code you need is listed below:
resources :deposits, :except => :edit
resources :deposits, :only => { :create, :new }
resources :deposits, :except => :edit
精彩评论