diff options
author | Zack Perdue <zack@ziggidycreative.com> | 2014-04-14 02:33:24 -0400 |
---|---|---|
committer | Zack Perdue <zack@ziggidycreative.com> | 2014-04-14 02:33:24 -0400 |
commit | cf786378e61760c3f7911f83ea31654986ea85f8 (patch) | |
tree | 7c6f489e474b7bbe4742b04c591e7a520d3aa8d4 /guides/source | |
parent | 6c002ba092f48136fe39908f40033d75b5bd46ac (diff) | |
download | rails-cf786378e61760c3f7911f83ea31654986ea85f8.tar.gz rails-cf786378e61760c3f7911f83ea31654986ea85f8.tar.bz2 rails-cf786378e61760c3f7911f83ea31654986ea85f8.zip |
Added documentation for the :param option for resourceful routing
Diffstat (limited to 'guides/source')
-rw-r--r-- | guides/source/routing.md | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/guides/source/routing.md b/guides/source/routing.md index 0783bce442..f6b1bc1509 100644 --- a/guides/source/routing.md +++ b/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 ----------------------------- |