aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorAndrew White <andrew.white@unboxed.co>2018-03-08 09:59:52 +0000
committerAndrew White <andrew.white@unboxed.co>2018-03-08 09:59:52 +0000
commit22777c80b4c6716c120c6c7f4f9221d58a679fad (patch)
tree1966bc6c87bd0603647c20cf21bd0542b14d1e35 /actionpack
parente764336e71c7dd386fbce36d0f916c41773a18cd (diff)
downloadrails-22777c80b4c6716c120c6c7f4f9221d58a679fad.tar.gz
rails-22777c80b4c6716c120c6c7f4f9221d58a679fad.tar.bz2
rails-22777c80b4c6716c120c6c7f4f9221d58a679fad.zip
Add example of maintaining context with `route_for`
[ci skip]
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/routing/url_for.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/routing/url_for.rb b/actionpack/lib/action_dispatch/routing/url_for.rb
index 922e776da9..872abacd53 100644
--- a/actionpack/lib/action_dispatch/routing/url_for.rb
+++ b/actionpack/lib/action_dispatch/routing/url_for.rb
@@ -203,6 +203,12 @@ module ActionDispatch
# route_for(:recordable, threadable.parent)
# end
#
+ # This maintains the context of the original caller on
+ # whether to return a path or full url, e.g:
+ #
+ # threadable_path(threadable) # => /buckets/1
+ # threadable_url(threadable) # => http://example.com/buckets/1
+ #
def route_for(name, *args)
public_send(:"#{name}_url", *args)
end