aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides
diff options
context:
space:
mode:
authoreparreno <emili@eparreno.com>2010-09-22 22:11:15 +0200
committereparreno <emili@eparreno.com>2010-09-22 22:11:15 +0200
commit5965219ca2230dc46cff2feace19d83b7493f440 (patch)
tree7e7331fce169bbe1d6be71a30c1e1f7ab2e6ceba /railties/guides
parentb39dfd5936ef25b04d6caad3ceb048c68a79ea12 (diff)
downloadrails-5965219ca2230dc46cff2feace19d83b7493f440.tar.gz
rails-5965219ca2230dc46cff2feace19d83b7493f440.tar.bz2
rails-5965219ca2230dc46cff2feace19d83b7493f440.zip
some fixes in routing guide
Diffstat (limited to 'railties/guides')
-rw-r--r--railties/guides/source/routing.textile10
1 files changed, 5 insertions, 5 deletions
diff --git a/railties/guides/source/routing.textile b/railties/guides/source/routing.textile
index 6c593a8da5..cfba58d8da 100644
--- a/railties/guides/source/routing.textile
+++ b/railties/guides/source/routing.textile
@@ -39,10 +39,10 @@ You can also generate paths and URLs. If your application contains this code:
</ruby>
<erb>
-<%= link_to "Patient Record", patients_path(@patient.id) %>
+<%= link_to "Patient Record", patient_path(@patient) %>
</erb>
-The router will generate the path +/patients/17+. This reduces the brittleness of your view and makes your code easier to understand.
+The router will generate the path +/patients/17+. This reduces the brittleness of your view and makes your code easier to understand. Note that the id does not need to be specified in the route helper.
h3. Resource Routing: the Rails Default
@@ -91,7 +91,7 @@ Creating a resourceful route will also expose a number of helpers to the control
* +photos_path+ returns +/photos+
* +new_photo_path+ returns +/photos/new+
-* +edit_photo_path+ returns +/photos/edit+
+* +edit_photo_path+ returns +/photos/:id/edit+
* +photo_path(id)+ returns +/photos/:id+ (for instance, +photo_path(10)+ returns +/photos/10+)
Each of these helpers has a corresponding +_url+ helper (such as +photos_url+) which returns the same path prefixed with the current host, port and path prefix.
@@ -370,7 +370,7 @@ When you set up a regular route, you supply a series of symbols that Rails maps
match ':controller(/:action(/:id))'
</ruby>
-If an incoming request of +/photos/show/1+ is processed by this route (because it hasn't matched any previous route in the file), then the result will be to invoke the +show+ action of the +PhotosController+, and to make the final parameter +"1"+ available as +params[:id]+. This route will also route the incoming request of +/photos+ to +PhotosController+, since +:action+ and +:id+ are optional parameters, denoted by parentheses.
+If an incoming request of +/photos/show/1+ is processed by this route (because it hasn't matched any previous route in the file), then the result will be to invoke the +show+ action of the +PhotosController+, and to make the final parameter +"1"+ available as +params[:id]+. This route will also route the incoming request of +/photos+ to +PhotosController#index+, since +:action+ and +:id+ are optional parameters, denoted by parentheses.
h4. Dynamic Segments
@@ -434,7 +434,7 @@ You can specify a name for any route using the +:as+ option.
match 'exit' => 'sessions#destroy', :as => :logout
</ruby>
-This will create +logout_path+ and +logout_url+ as named helpers in your application. Calling +logout_path+ will return +/logout+
+This will create +logout_path+ and +logout_url+ as named helpers in your application. Calling +logout_path+ will return +/exit+
h4. Segment Constraints