From 04289172cb568b7f17eba93da79f158f3192edea Mon Sep 17 00:00:00 2001 From: eparreno Date: Thu, 13 May 2010 16:12:25 +0200 Subject: routing guide: fix typos and clarify code examples --- railties/guides/source/routing.textile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/railties/guides/source/routing.textile b/railties/guides/source/routing.textile index 7ac5bc8d3a..2bc1736137 100644 --- a/railties/guides/source/routing.textile +++ b/railties/guides/source/routing.textile @@ -118,6 +118,12 @@ h4. Singular Resources Sometimes, you have a resource that clients always look up without referencing an ID. A common example, +/profile+ always shows the profile of the currently logged in user. In this case, you can use a singular resource to map +/profile+ (rather than +/profile/:id+) to the +show+ action. + +match "profile" => "users#show" + + +This resourceful route + resource :geocoder @@ -391,7 +397,7 @@ h4. The Query String The +params+ will also include any parameters from the query string. For example, with this route: -match ':controller/:action/:id +match ':controller/:action/:id' An incoming URL of +/photos/show/1?user_id=2+ will be dispatched to the +show+ action of the +Photos+ controller. +params+ will be { :controller => "photos", :action => "show", :id => "1", :user_id => "2" }. @@ -419,7 +425,7 @@ h4. Naming Routes You can specify a name for any route using the +:as+ option. -match 'logout' => 'sessions#destroy', :as => :logout +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 +/logout+ @@ -636,7 +642,7 @@ end resources :photos -This will provide route helpers such as +photographer_photos_path+. +This will provide route helpers such as +admin_photos_path+, +new_admin_photo_path+ etc. You could specify a name prefix to use for a group of routes in the scope: -- cgit v1.2.3