Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/lifo/docrails
Browse files Browse the repository at this point in the history
  • Loading branch information
fxn committed Dec 31, 2010
2 parents e5b84fd + 224e2d4 commit 65d3899
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion railties/guides/source/routing.textile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit 65d3899

Please sign in to comment.