Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:zackperdue/rails into zackperdue-…

…master
  • Loading branch information...
commit ec7fee498291b90983cf130a81ad1647b10f1c8b 2 parents 03ee419 + cf78637
@zzak zzak authored
Showing with 19 additions and 0 deletions.
  1. +19 −0 guides/source/routing.md
View
19 guides/source/routing.md
@@ -1044,6 +1044,25 @@ end
This will create routing helpers such as `magazine_periodical_ads_url` and `edit_magazine_periodical_ad_path`.
+### Overriding Named Route Parameters
+
+The `:param` option overrides the default resource identifier `:id` allowing you to use the specified name in your controller action to find the specific resource in the database.
+
+```ruby
+resources :videos, param: :identifier
+```
+
+```
+ videos GET /videos(.:format) videos#index
+ POST /videos(.:format) videos#create
+ new_videos GET /videos/new(.:format) videos#new
+edit_videos GET /videos/:identifier/edit(.:format) videos#edit
+```
+
+```ruby
+Video.find_by(identifier: params[:identifier])
+```
+
Inspecting and Testing Routes
-----------------------------
Please sign in to comment.
Something went wrong with that request. Please try again.