diff options
author | bogdanvlviv <bogdanvlviv@gmail.com> | 2018-03-05 21:24:11 +0200 |
---|---|---|
committer | bogdanvlviv <bogdanvlviv@gmail.com> | 2018-03-07 00:58:16 +0200 |
commit | 046750aeeb71302fa27b63b74b5ae6cee9827401 (patch) | |
tree | 1929d2749837a7fd42e514c6364238b2587b1df5 /actionpack | |
parent | e83575ff533690db86c92447a539d76b648e9fed (diff) | |
download | rails-046750aeeb71302fa27b63b74b5ae6cee9827401.tar.gz rails-046750aeeb71302fa27b63b74b5ae6cee9827401.tar.bz2 rails-046750aeeb71302fa27b63b74b5ae6cee9827401.zip |
Express `ActionDispatch::Routing::UrlFor#route_for` as public api
This method was added by #28462 but marked as private api.
Since `route_for` looks good in pair with `ActionDispatch::Routing::Mapper::CustomUrls#direct`
let's make it as public api.
We use it in https://github.com/rails/rails/blob/e83575ff533690db86c92447a539d76b648e9fed/activestorage/config/routes.rb
Closes #31417
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/url_for.rb | 14 |
1 files changed, 13 insertions, 1 deletions
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 @@ module ActionDispatch 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 |