Skip to content

Commit

Permalink
Merge pull request #32175 from bogdanvlviv/express-route_for-as-publi…
Browse files Browse the repository at this point in the history
…c-api

Express `ActionDispatch::Routing::UrlFor#route_for` as public api
  • Loading branch information
pixeltrix committed Mar 8, 2018
2 parents 6a54932 + 046750a commit e764336
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion actionpack/lib/action_dispatch/routing/url_for.rb
Expand Up @@ -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

Expand Down

0 comments on commit e764336

Please sign in to comment.