:exceptoptions to RESTful routes.
map.resourcescreates routes for all seven of the default actions (index, show, new, create, edit, update, and destroy) for the resource. But in Rails 2.2 (or in the current edge builds), you can fine-tune this behavior. The
:onlyoption specifies that only certain routes should be generated:
map.resources :customers, :only => [:index, :show, :destroy]
As with most places in Rails, you can use
:exceptas the opposite of
map.resources :customers, :except => :index
That declaration would give you six of the seven default routes, omitting only a route for the index action.
In addition to an action or an array of actions, you can also supply the special symbols
Why do this? In addition to making your code easier to follow, the smaller you can make the routing table, the less memory it will take up - and the less processing time route recognition and generation will take. It can also lower the attack surface of your application by removing unused routes, which is a security win.