aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/source/routing.textile
diff options
context:
space:
mode:
authorRyan Bigg <radarlistener@gmail.com>2010-12-31 17:38:04 +1000
committerRyan Bigg <radarlistener@gmail.com>2010-12-31 17:38:38 +1000
commiteaf67ca9c3fbe3e45c8096ea7ffbde562ebfb76d (patch)
tree065e5214f05bb4679ce598ff4c881021d5e24e3e /railties/guides/source/routing.textile
parent69765aad8bcc853e7ab6b0e79f4edece2cdd7fe2 (diff)
downloadrails-eaf67ca9c3fbe3e45c8096ea7ffbde562ebfb76d.tar.gz
rails-eaf67ca9c3fbe3e45c8096ea7ffbde562ebfb76d.tar.bz2
rails-eaf67ca9c3fbe3e45c8096ea7ffbde562ebfb76d.zip
Routing guide: improve documentation for the scope method, demonstrating use of named parameters
Diffstat (limited to 'railties/guides/source/routing.textile')
-rw-r--r--railties/guides/source/routing.textile10
1 files changed, 10 insertions, 0 deletions
diff --git a/railties/guides/source/routing.textile b/railties/guides/source/routing.textile
index 15b26d8f9e..fda5c6c668 100644
--- a/railties/guides/source/routing.textile
+++ b/railties/guides/source/routing.textile
@@ -200,6 +200,16 @@ or, for a single case
resources :posts, :path => "/admin/posts"
</ruby>
+You can even set named parameters for the paths:
+
+<ruby>
+scope ":username" do
+ resources :posts
+end
+</ruby>
+
+This will provide you with URLs such as +/bob/posts/1+ and will allow you to reference the +username+ part of the path as +params[:username]+ in controllers, helpers and views.
+
In each of these cases, the named routes remain the same as if you did not use +scope+. In the last case, the following paths map to +PostsController+:
|_.HTTP Verb |_.Path |_.action |_.named helper |