提交 706a3223 编写于 作者: P Piotr Sarnacki

Add short note on using url_for instead of directly calling named route in polymorphic_url

上级 613cbe1f
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册