aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/source/routing.textile
diff options
context:
space:
mode:
authorJames Miller <bensie@gmail.com>2010-11-15 09:26:57 -0700
committerJames Miller <bensie@gmail.com>2010-11-15 09:26:57 -0700
commitc2c2b8b96220b11eb3512b1eaaf7985c84f03d67 (patch)
tree0ade05b4a6e48b25196c64c042efd46e61bd758f /railties/guides/source/routing.textile
parent8b5700192e3baadf236f1d7560c3b9f979b3b56d (diff)
downloadrails-c2c2b8b96220b11eb3512b1eaaf7985c84f03d67.tar.gz
rails-c2c2b8b96220b11eb3512b1eaaf7985c84f03d67.tar.bz2
rails-c2c2b8b96220b11eb3512b1eaaf7985c84f03d67.zip
Add HTTP Verb Constraints (:via) to routing guide
Diffstat (limited to 'railties/guides/source/routing.textile')
-rw-r--r--railties/guides/source/routing.textile20
1 files changed, 20 insertions, 0 deletions
diff --git a/railties/guides/source/routing.textile b/railties/guides/source/routing.textile
index f48ae9c7f7..cc0c3316c8 100644
--- a/railties/guides/source/routing.textile
+++ b/railties/guides/source/routing.textile
@@ -436,6 +436,26 @@ match 'exit' => 'sessions#destroy', :as => :logout
This will create +logout_path+ and +logout_url+ as named helpers in your application. Calling +logout_path+ will return +/exit+
+h4. HTTP Verb Constraints
+
+You can use the +:via+ option to constrain the request to one or more HTTP methods:
+
+<ruby>
+match 'photos/show' => 'photos#show', :via => :get
+</ruby>
+
+There is a shorthand version of this as well:
+
+<ruby>
+get 'photos/show'
+</ruby>
+
+You can also permit more than one verb to a single route:
+
+<ruby>
+match 'photos/show' => 'photos#show', :via => [:get, :post]
+</ruby>
+
h4. Segment Constraints
You can use the +:constraints+ option to enforce a format for a dynamic segment: