mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Can't cache url_options on a controller level
It fails if routes from to railties are called in one context, for example: blog.posts_path and main_app.users_path
This commit is contained in:
parent
d08a7c1818
commit
0e94208a0f
1 changed files with 12 additions and 11 deletions
|
@ -26,19 +26,20 @@ module ActionController
|
||||||
include AbstractController::UrlFor
|
include AbstractController::UrlFor
|
||||||
|
|
||||||
def url_options
|
def url_options
|
||||||
@_url_options ||= begin
|
@_url_options ||= super.reverse_merge(
|
||||||
hash = super.reverse_merge(
|
:host => request.host,
|
||||||
:host => request.host,
|
:port => request.optional_port,
|
||||||
:port => request.optional_port,
|
:protocol => request.protocol,
|
||||||
:protocol => request.protocol,
|
:_path_segments => request.symbolized_path_parameters
|
||||||
:_path_segments => request.symbolized_path_parameters
|
).freeze
|
||||||
)
|
|
||||||
|
|
||||||
if _routes.equal?(env["action_dispatch.routes"])
|
if _routes.equal?(env["action_dispatch.routes"])
|
||||||
hash[:script_name] = request.script_name.dup
|
@_url_options.dup.tap do |options|
|
||||||
|
options[:script_name] = request.script_name.dup
|
||||||
|
options.freeze
|
||||||
end
|
end
|
||||||
|
else
|
||||||
hash.freeze
|
@_url_options
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue