Update guides/source/routing.md

This commit is contained in:
Bryan Larsen 2012-09-25 13:29:53 -03:00
parent bfafa999dd
commit 2029c2ac18

@ -401,6 +401,18 @@ resources :photos do
end
```
#### Adding Routes for Additional New Actions
To add an alternate new action using the `:on` shortcut:
```ruby
resources :comments do
get 'preview', :on => :new
end
```
This will enable Rails to recognize paths such as `/comments/new/preview` with GET, and route to the `preview` action of `CommentsController`. It will also create the `preview_new_comment_url` and `preview_new_comment_path` route helpers.
#### A Note of Caution
If you find yourself adding many extra actions to a resourceful route, it's time to stop and ask yourself whether you're disguising the presence of another resource.