diff options
Diffstat (limited to 'actionpack/lib/action_controller/metal/url_for.rb')
-rw-r--r-- | actionpack/lib/action_controller/metal/url_for.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/metal/url_for.rb b/actionpack/lib/action_controller/metal/url_for.rb index a51fc5b8e4..ca91e1f362 100644 --- a/actionpack/lib/action_controller/metal/url_for.rb +++ b/actionpack/lib/action_controller/metal/url_for.rb @@ -5,11 +5,20 @@ module ActionController include ActionDispatch::Routing::UrlFor def url_options - super.reverse_merge( + options = {} + if respond_to?(:env) && env + if _routes.equal?(env["action_dispatch.routes"]) + options[:skip_prefix] = true + elsif env["action_dispatch.routes"] + options[:script_name] = _routes.default_url_options[:script_name] + end + end + + super.merge(options).reverse_merge( :host => request.host_with_port, :protocol => request.protocol, :_path_segments => request.symbolized_path_parameters - ).merge(:script_name => request.script_name) + ).reverse_merge(:script_name => request.script_name) end def _routes |