Permalink
Browse files

Routing guide: improve documentation for the scope method, demonstrat…

…ing use of named parameters
  • Loading branch information...
1 parent 69765aa commit eaf67ca9c3fbe3e45c8096ea7ffbde562ebfb76d @radar radar committed Dec 31, 2010
Showing with 10 additions and 0 deletions.
  1. +10 −0 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 |

0 comments on commit eaf67ca

Please sign in to comment.