aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/routing.md
diff options
context:
space:
mode:
Diffstat (limited to 'guides/source/routing.md')
-rw-r--r--guides/source/routing.md14
1 files changed, 14 insertions, 0 deletions
diff --git a/guides/source/routing.md b/guides/source/routing.md
index 52f11f92bd..02763eabcd 100644
--- a/guides/source/routing.md
+++ b/guides/source/routing.md
@@ -1087,6 +1087,20 @@ edit_videos GET /videos/:identifier/edit(.:format) videos#edit
Video.find_by(identifier: params[:identifier])
```
+You can override `ActiveRecord::Base#to_param` of a related
+model to constructe an URL.
+
+```ruby
+class Video < ActiveRecord::Base
+ def to_param # overridden
+ identifier
+ end
+end
+
+video = Video.find_by(identifier: "Roman-Holiday")
+edit_videos_path(video) # => "/videos/Roman-Holiday"
+```
+
Inspecting and Testing Routes
-----------------------------