Skip to content

Commit

Permalink
some fixes in routing guide
Browse files Browse the repository at this point in the history
  • Loading branch information
eparreno committed Sep 22, 2010
1 parent b39dfd5 commit 5965219
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions railties/guides/source/routing.textile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 5965219

Please sign in to comment.