aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides
diff options
context:
space:
mode:
authorRizwan Reza <rizwanreza@gmail.com>2010-04-05 19:37:49 +0430
committerRizwan Reza <rizwanreza@gmail.com>2010-04-05 19:37:49 +0430
commitf5c54bce20933b6d48dd9f41b49839302c1335f7 (patch)
treeca7df5d60393d40d8c55ee52c19a57e28b5605b0 /railties/guides
parenta0e4bb9b5c8516b6e6c2db7bdbcffa267f76ba1b (diff)
downloadrails-f5c54bce20933b6d48dd9f41b49839302c1335f7.tar.gz
rails-f5c54bce20933b6d48dd9f41b49839302c1335f7.tar.bz2
rails-f5c54bce20933b6d48dd9f41b49839302c1335f7.zip
Routes Guide: Added Section on customizing path names for resources.
Diffstat (limited to 'railties/guides')
-rw-r--r--railties/guides/source/routing.textile23
1 files changed, 22 insertions, 1 deletions
diff --git a/railties/guides/source/routing.textile b/railties/guides/source/routing.textile
index 0cf8c45761..cf71e700dc 100644
--- a/railties/guides/source/routing.textile
+++ b/railties/guides/source/routing.textile
@@ -364,6 +364,27 @@ In this case, all of the normal routes except the route for +destroy+ (a +DELETE
TIP: If your application has many RESTful routes, using +:only+ and +:except+ to generate only the routes that you actually need can cut down on memory use and speed up the routing process.
+h5. Changing Path Names for Resources
+
+Using +scope+, we can alter path names generated by resources:
+
+<ruby>
+scope(:resources_path_names => { :new => "neu", :edit => "bearbeiten" }) do
+ resources :categories, :path => "kategorien"
+end
+</ruby>
+
+With +scope+ defined, it now generates routes with customized path names.
+
+|_.HTTP verb|_.URL |_.controller |_.action |_:used for|
+|GET |/kategorien |Categories |index |display a list of all categories|
+|GET |/kategorien/neu |Categories |new |return an HTML form for creating a new category|
+|POST |/kategorien |Categories |create |create a new category|
+|GET |/kategorien/1 |Categories |show |display a specific category|
+|GET |/kategorien/:id/bearbeiten |Categories |edit |return an HTML form for editing a category|
+|PUT |/kategorien/1 |Categories |update |update a specific category|
+|DELETE |/kategorien/1 |Categories |destroy |delete a specific category|
+
h4. Nested Resources
It's common to have resources that are logically children of other resources. For example, suppose your application includes these models:
@@ -809,7 +830,7 @@ h3. Changelog
"Lighthouse ticket":http://rails.lighthouseapp.com/projects/16213-rails-guides/tickets/3
-* April 2, 2010: Updated guide to match new Routing DSL in Rails 3, by Rizwan Reza
+* April 2, 2010: Updated guide to match new Routing DSL in Rails 3, by "Rizwan Reza":http://www.rizwanreza.com/
* Febuary 1, 2010: Modifies the routing documentation to match new routing DSL in Rails 3, by Prem Sichanugrist
* October 4, 2008: Added additional detail on specifying verbs for resource member/collection routes, by "Mike Gunderloy":credits.html#mgunderloy
* September 23, 2008: Added section on namespaced controllers and routing, by "Mike Gunderloy":credits.html#mgunderloy