aboutsummaryrefslogtreecommitdiffstats
path: root/railties/doc/guides/routing/routing_outside_in.txt
diff options
context:
space:
mode:
authorMike Gunderloy <MikeG1@larkfarm.com>2008-10-04 09:06:57 -0500
committerMike Gunderloy <MikeG1@larkfarm.com>2008-10-04 09:06:57 -0500
commit01159a6431bbc2dc7d7d95ce294c8567c954f39e (patch)
treec3112553b1f5e1eca4651c87706c6a6ab8368135 /railties/doc/guides/routing/routing_outside_in.txt
parent70d4cbb837c1b494e5572be428a9517277be909d (diff)
downloadrails-01159a6431bbc2dc7d7d95ce294c8567c954f39e.tar.gz
rails-01159a6431bbc2dc7d7d95ce294c8567c954f39e.tar.bz2
rails-01159a6431bbc2dc7d7d95ce294c8567c954f39e.zip
Additional detail on specifying verbs for resource member and collection routes.
Diffstat (limited to 'railties/doc/guides/routing/routing_outside_in.txt')
-rw-r--r--railties/doc/guides/routing/routing_outside_in.txt17
1 files changed, 15 insertions, 2 deletions
diff --git a/railties/doc/guides/routing/routing_outside_in.txt b/railties/doc/guides/routing/routing_outside_in.txt
index 2c1870d9d4..f35ac0cebd 100644
--- a/railties/doc/guides/routing/routing_outside_in.txt
+++ b/railties/doc/guides/routing/routing_outside_in.txt
@@ -568,7 +568,12 @@ map.resources :photos, :member => { :preview => :get }
This will enable Rails to recognize URLs such as +/photos/1/preview+ using the GET HTTP verb, and route them to the preview action of the Photos controller. It will also create a +preview_photo+ route helper.
-Within the hash of member routes, each route name specifies the HTTP verb that it will recognize. You can use +:get+, +:put+, +:post+, +:delete+, or +:any+ here.
+Within the hash of member routes, each route name specifies the HTTP verb that it will recognize. You can use +:get+, +:put+, +:post+, +:delete+, or +:any+ here. You can also specify an array of methods, if you need more than one but you don't want to allow just anything:
+
+[source, ruby]
+-------------------------------------------------------
+map.resources :photos, :member => { :prepare => [:get, :post] }
+-------------------------------------------------------
==== Adding Collection Routes
@@ -581,6 +586,13 @@ map.resources :photos, :collection => { :search => :get }
This will enable Rails to recognize URLs such as +/photos/search+ using the GET HTTP verb, and route them to the search action of the Photos controller. It will also create a +search_photos+ route helper.
+Just as with member routes, you can specify an array of methods for a collection route:
+
+[source, ruby]
+-------------------------------------------------------
+map.resources :photos, :collection => { :search => [:get, :post] }
+-------------------------------------------------------
+
==== Adding New Routes
To add a new route (one that creates a new resource), use the +:new+ option:
@@ -904,5 +916,6 @@ assert_routing { :path => "photos", :method => :post }, { :controller => "photos
http://rails.lighthouseapp.com/projects/16213-rails-guides/tickets/3[Lighthouse ticket]
-* September 10, 2008: initial version by link:../authors.html#mgunderloy[Mike Gunderloy]
+* October 4, 2008: Added additional detail on specifying verbs for resource member/collection routes , by link:../authors.html#mgunderloy[Mike Gunderloy]
* September 23, 2008: Added section on namespaced controllers and routing, by link:../authors.html#mgunderloy[Mike Gunderloy]
+* September 10, 2008: initial version by link:../authors.html#mgunderloy[Mike Gunderloy]