Reputation: 6496
I have a rails app and I have some custom routes. I have a database called Reports. In my routes.rb i have match '/new' => 'reports#new'
however the problem is that /new goes to the right place, but /reports/new is also still active. Is there a way to "deactivate" the standard /reports/new so that only /new works?
Upvotes: 2
Views: 4261
Reputation: 11198
Sure, there is. You can use the only
option as in (for example):
resources :reports, :only => [:create, :edit, :update]
which defines routes only for the specified actions (run rake routes
to see all the routes)
(so it doesn't remove routes, it just does not generate them)
Edit: Plus, of course, there's also the except
option (also see @Andy Gaskell's anwers) - which generates all routes except for the given actions, see the docs.
Upvotes: 6
Reputation: 31761
If you're only interested in disabling one action except
may be more appropriate than only
. It works in a similar way.
... :except => :new
http://guides.rubyonrails.org/routing.html#restricting-the-routes-created
Upvotes: 6