From 2029c2ac18c12a08f0ddfdcadf90e50c54520895 Mon Sep 17 00:00:00 2001 From: Bryan Larsen Date: Tue, 25 Sep 2012 13:29:53 -0300 Subject: Update guides/source/routing.md --- guides/source/routing.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'guides/source') diff --git a/guides/source/routing.md b/guides/source/routing.md index 27fd2a35c4..3acb7fa0e5 100644 --- a/guides/source/routing.md +++ b/guides/source/routing.md @@ -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. -- cgit v1.2.3