Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add short note on using url_for instead of directly calling named rou…

…te in polymorphic_url
  • Loading branch information...
commit 706a3223a303d56feeee2cc7601da1bd9f381243 1 parent 613cbe1
@drogus drogus authored
Showing with 3 additions and 0 deletions.
  1. +3 −0  actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
View
3  actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
@@ -129,6 +129,9 @@ def polymorphic_url(record_or_hash_or_array, options = {})
if proxy
proxy.send(named_route, *args)
else
+ # we need to use url_for, because polymorphic_url can be used in context of other than
+ # current routes (e.g. engine's routes). As named routes from engine are not included
+ # calling engine's named route directly would fail.
url_for _routes.url_helpers.__send__("hash_for_#{named_route}", *args)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.