aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/source/routing.textile
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2010-12-31 10:22:34 +0100
committerXavier Noria <fxn@hashref.com>2010-12-31 10:22:34 +0100
commit65d389955f164714cd6567918c25385e17c5b844 (patch)
tree3133cd7af74c4cbac14396cf8f5cdf6e8d071370 /railties/guides/source/routing.textile
parente5b84fd72358deddd29c515aacab7edf2643908e (diff)
parent224e2d478a825c312128a1b3c2797d0a95fd7109 (diff)
downloadrails-65d389955f164714cd6567918c25385e17c5b844.tar.gz
rails-65d389955f164714cd6567918c25385e17c5b844.tar.bz2
rails-65d389955f164714cd6567918c25385e17c5b844.zip
Merge branch 'master' of git://github.com/lifo/docrails
Diffstat (limited to 'railties/guides/source/routing.textile')
-rw-r--r--railties/guides/source/routing.textile14
1 files changed, 13 insertions, 1 deletions
diff --git a/railties/guides/source/routing.textile b/railties/guides/source/routing.textile
index 15b26d8f9e..f60d72352d 100644
--- a/railties/guides/source/routing.textile
+++ b/railties/guides/source/routing.textile
@@ -704,7 +704,7 @@ resources :photos
This will provide route helpers such as +admin_photos_path+, +new_admin_photo_path+ etc.
-To prefix a group of routes, use +:as+ with +scope+:
+To prefix a group of route helpers, use +:as+ with +scope+:
<ruby>
scope "admin", :as => "admin" do
@@ -714,8 +714,20 @@ end
resources :photos, :accounts
</ruby>
+This will generate routes such as +admin_photos_path+ and +admin_accounts_path+ which map to +/admin/photos+ and +/admin/accounts+ respectively.
+
NOTE: The +namespace+ scope will automatically add +:as+ as well as +:module+ and +:path+ prefixes.
+You can prefix routes with a named parameter also:
+
+<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.
+
h4. Restricting the Routes Created
By default, Rails creates routes for the seven default actions (index, show, new, create, edit, update, and destroy) for every RESTful route in your application. You can use the +:only+ and +:except+ options to fine-tune this behavior. The +:only+ option tells Rails to create only the specified routes: