aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2012-03-02 18:47:15 +0100
committerPiotr Sarnacki <drogus@gmail.com>2012-03-02 18:47:15 +0100
commit0e94208a0fd949b61fc5b297611cdf21eca329bf (patch)
tree294579d5f24d34afdf1d4a4f7351489bd0061bc1
parentd08a7c18183e74707f5f734f696c7e1cd1acd050 (diff)
downloadrails-0e94208a0fd949b61fc5b297611cdf21eca329bf.tar.gz
rails-0e94208a0fd949b61fc5b297611cdf21eca329bf.tar.bz2
rails-0e94208a0fd949b61fc5b297611cdf21eca329bf.zip
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
-rw-r--r--actionpack/lib/action_controller/metal/url_for.rb23
1 files changed, 12 insertions, 11 deletions
diff --git a/actionpack/lib/action_controller/metal/url_for.rb b/actionpack/lib/action_controller/metal/url_for.rb
index 4504d9cd10..1177a703b3 100644
--- a/actionpack/lib/action_controller/metal/url_for.rb
+++ b/actionpack/lib/action_controller/metal/url_for.rb
@@ -26,19 +26,20 @@ module ActionController
include AbstractController::UrlFor
def url_options
- @_url_options ||= begin
- hash = super.reverse_merge(
- :host => request.host,
- :port => request.optional_port,
- :protocol => request.protocol,
- :_path_segments => request.symbolized_path_parameters
- )
+ @_url_options ||= super.reverse_merge(
+ :host => request.host,
+ :port => request.optional_port,
+ :protocol => request.protocol,
+ :_path_segments => request.symbolized_path_parameters
+ ).freeze
- if _routes.equal?(env["action_dispatch.routes"])
- hash[:script_name] = request.script_name.dup
+ if _routes.equal?(env["action_dispatch.routes"])
+ @_url_options.dup.tap do |options|
+ options[:script_name] = request.script_name.dup
+ options.freeze
end
-
- hash.freeze
+ else
+ @_url_options
end
end
end