开发者

Removing a route

开发者 https://www.devze.com 2023-03-26 16:02 出处:网络
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 wa

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
0

精彩评论

暂无评论...
验证码 换一张
取 消