From c2c2b8b96220b11eb3512b1eaaf7985c84f03d67 Mon Sep 17 00:00:00 2001 From: James Miller Date: Mon, 15 Nov 2010 09:26:57 -0700 Subject: Add HTTP Verb Constraints (:via) to routing guide --- railties/guides/source/routing.textile | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'railties/guides/source') 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: + + +match 'photos/show' => 'photos#show', :via => :get + + +There is a shorthand version of this as well: + + +get 'photos/show' + + +You can also permit more than one verb to a single route: + + +match 'photos/show' => 'photos#show', :via => [:get, :post] + + h4. Segment Constraints You can use the +:constraints+ option to enforce a format for a dynamic segment: -- cgit v1.2.3