Skip to content

Commit

Permalink
Changes for routing from the outside in guide
Browse files Browse the repository at this point in the history
Fix some lingering typos.
Add a description to the index page.
  • Loading branch information
Mike Gunderloy authored and Mike Gunderloy committed Sep 13, 2008
1 parent 8373921 commit ae3dcd3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion railties/doc/guides/index.txt
Expand Up @@ -36,7 +36,8 @@ avoid them with Rails.

.link:routing/routing_outside_in.html[Rails Routing from the Outside In]
***********************************************************
TODO: Insert some description here.
This guide covers the user-facing features of Rails routing. If you want to
understand how to use routing in your own Rails applications, start here.
***********************************************************

.link:debugging/debugging_rails_applications.html[Debugging Rails Applications]
Expand Down
18 changes: 9 additions & 9 deletions railties/doc/guides/routing/routing_outside_in.txt
Expand Up @@ -127,7 +127,7 @@ In Rails, a RESTful route provides a mapping between HTTP verbs, controller acti

[source, ruby]
-------------------------------------------------------
map.resources photos
map.resources :photos
-------------------------------------------------------

creates seven different routes in your application:
Expand Down Expand Up @@ -174,7 +174,7 @@ You can also apply RESTful routing to singleton resources within your applicatio

[source, ruby]
-------------------------------------------------------
map.resource geocoder
map.resource :geocoder
-------------------------------------------------------

creates seven different routes in your application:
Expand Down Expand Up @@ -220,7 +220,7 @@ The +:controller+ option lets you use a controller name that is different from t

[source, ruby]
-------------------------------------------------------
map.resources photos, :controller => "images"
map.resources :photos, :controller => "images"
-------------------------------------------------------

will recognize incoming URLs containing +photo+ but route the requests to the Images controller:
Expand Down Expand Up @@ -257,7 +257,7 @@ You an use the +:requirements+ option in a RESTful route to impose a format on t

[source, ruby]
-------------------------------------------------------
map.resources photos, :requirements => {:id => /[A-Z][A-Z][0-9]+/}
map.resources :photos, :requirements => {:id => /[A-Z][A-Z][0-9]+/}
-------------------------------------------------------

This declaration constrains the +:id+ parameter to match the supplied regular expression. So, in this case, +/photos/1+ would no longer be recognized by this route, but +/photos/RR27+ would.
Expand All @@ -272,7 +272,7 @@ The +:as+ option lets you override the normal naming for the actual generated pa

[source, ruby]
-------------------------------------------------------
map.resources photos, :as => "images"
map.resources :photos, :as => "images"
-------------------------------------------------------

will recognize incoming URLs containing +image+ but route the requests to the Photos controller:
Expand All @@ -298,7 +298,7 @@ The +:path_names+ option lets you override the automatically-generated "new" and

[source, ruby]
-------------------------------------------------------
map.resources photos, :path_names => { :new => 'make', :edit => 'change' }
map.resources :photos, :path_names => { :new => 'make', :edit => 'change' }
-------------------------------------------------------

This would cause the routing to recognize URLs such as
Expand All @@ -323,7 +323,7 @@ The +:path_prefix+ option lets you add additional parameters that will be prefix

[source, ruby]
-------------------------------------------------------
map.resources photos, :path_prefix => '/photographers/:photographer_id'
map.resources :photos, :path_prefix => '/photographers/:photographer_id'
-------------------------------------------------------

Routes recognized by this entry would include:
Expand All @@ -341,8 +341,8 @@ You can use the :name_prefix option to avoid collisions between routes. This is

[source, ruby]
-------------------------------------------------------
map.resources photos, :path_prefix => '/photographers/:photographer_id', :name_prefix => 'photographer_'
map.resources photos, :path_prefix => '/agencies/:agency_id', :name_prefix => 'agency_'
map.resources :photos, :path_prefix => '/photographers/:photographer_id', :name_prefix => 'photographer_'
map.resources :photos, :path_prefix => '/agencies/:agency_id', :name_prefix => 'agency_'
-------------------------------------------------------

This combination will give you route helpers such as +photographer_photos_path+ and +agency_photo_edit_path+ to use in your code.
Expand Down

0 comments on commit ae3dcd3

Please sign in to comment.