Skip to content

Commit

Permalink
Update guides/source/routing.md
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanlarsen committed Sep 25, 2012
1 parent bfafa99 commit 2029c2a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions guides/source/routing.md
Expand Up @@ -401,6 +401,18 @@ resources :photos do
end 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 #### 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. 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.
Expand Down

0 comments on commit 2029c2a

Please sign in to comment.