From 15ecf32aa96ff0e946cb3040bdffa2c5e5126451 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Thu, 8 Mar 2018 09:49:36 +0000 Subject: [PATCH] Merge pull request #32175 from bogdanvlviv/express-route_for-as-public-api Express `ActionDispatch::Routing::UrlFor#route_for` as public api (cherry picked from commit e764336e71c7dd386fbce36d0f916c41773a18cd) --- actionpack/lib/action_dispatch/routing/url_for.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/actionpack/lib/action_dispatch/routing/url_for.rb b/actionpack/lib/action_dispatch/routing/url_for.rb index fa345dccdf..922e776da9 100644 --- a/actionpack/lib/action_dispatch/routing/url_for.rb +++ b/actionpack/lib/action_dispatch/routing/url_for.rb @@ -191,7 +191,19 @@ def full_url_for(options = nil) # :nodoc: end end - def route_for(name, *args) # :nodoc: + # Allows calling direct or regular named route. + # + # resources :buckets + # + # direct :recordable do |recording| + # route_for(:bucket, recording.bucket) + # end + # + # direct :threadable do |threadable| + # route_for(:recordable, threadable.parent) + # end + # + def route_for(name, *args) public_send(:"#{name}_url", *args) end -- GitLab