aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-09-24 19:47:45 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-09-24 19:47:45 +0000
commit40f9fd39f6b471cb35b551b456f2c22d52f1b825 (patch)
treefe2256c63d0dc00ed0d2fd6a8bc33e0e21e18d16 /actionpack/lib/action_view
parent605aadb3cdba9f469e88c39c0cad7448d59a9f0c (diff)
downloadrails-40f9fd39f6b471cb35b551b456f2c22d52f1b825.tar.gz
rails-40f9fd39f6b471cb35b551b456f2c22d52f1b825.tar.bz2
rails-40f9fd39f6b471cb35b551b456f2c22d52f1b825.zip
Include asset host in public path cache key. Clear cache between asset tag tests.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7617 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r--actionpack/lib/action_view/base.rb4
-rw-r--r--actionpack/lib/action_view/helpers/asset_tag_helper.rb22
2 files changed, 17 insertions, 9 deletions
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index 3aa0c610f7..4f5fb7d4be 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionpack/lib/action_view/base.rb
@@ -223,6 +223,10 @@ module ActionView #:nodoc:
# Maps template paths / extensions to
@@cached_base_paths = {}
+ # Cache public asset paths
+ cattr_reader :computed_public_paths
+ @@computed_public_paths = {}
+
@@templates_requiring_setup = Set.new(%w(builder rxml rjs))
# Order of template handers checked by #file_exists? depending on the current #template_format
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
index fd311fadfc..83bc33bd3b 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -384,8 +384,12 @@ module ActionView
# a single or wildcarded asset host, if configured, with the correct
# request protocol.
def compute_public_path(source, dir, ext = nil, include_host = true)
- @@computed_public_paths ||= {}
- @@computed_public_paths["#{@controller.request.protocol}#{@controller.request.relative_url_root}#{dir}#{source}#{ext}#{include_host}"] ||=
+ cache_key = [ @controller.request.protocol,
+ ActionController::Base.asset_host,
+ @controller.request.relative_url_root,
+ dir, source, ext, include_host ].join
+
+ ActionView::Base.computed_public_paths[cache_key] ||=
begin
source += ".#{ext}" if File.extname(source).blank? && ext
@@ -426,15 +430,15 @@ module ActionView
if asset_id = ENV["RAILS_ASSET_ID"]
asset_id
else
- @@asset_id_cache[source] ||=
- if file_exist?(path = File.join(ASSETS_DIR, source))
- File.mtime(path).to_i.to_s
- else
- ''
- end
+ path = File.join(ASSETS_DIR, source)
+
+ if File.exist?(path)
+ File.mtime(path).to_i.to_s
+ else
+ ''
+ end
end
end
- @@asset_id_cache = {}
# Break out the asset path rewrite so you wish to put the asset id
# someplace other than the query string.