diff options
author | James Miller <bensie@gmail.com> | 2010-11-15 09:26:57 -0700 |
---|---|---|
committer | James Miller <bensie@gmail.com> | 2010-11-15 09:26:57 -0700 |
commit | c2c2b8b96220b11eb3512b1eaaf7985c84f03d67 (patch) | |
tree | 0ade05b4a6e48b25196c64c042efd46e61bd758f /railties/guides/source/routing.textile | |
parent | 8b5700192e3baadf236f1d7560c3b9f979b3b56d (diff) | |
download | rails-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.textile | 20 |
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: |