Permalink
Browse files

compute_public_path behaves well with mailers also. Closes #10014.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8052 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
jeremy committed Oct 29, 2007
1 parent 204c275 commit c240f2d48a3677954c4bcb57c36587833cbda2c0
Showing with 16 additions and 6 deletions.
  1. +16 −6 actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -387,10 +387,18 @@ def file_exist?(path)
# a single or wildcarded asset host, if configured, with the correct
# request protocol.
def compute_public_path(source, dir, ext = nil, include_host = true)
- cache_key = [ @controller.request.protocol,
- ActionController::Base.asset_host,
- @controller.request.relative_url_root,
- dir, source, ext, include_host ].join
+ has_request = @controller.respond_to?(:request)
+
+ cache_key =
+ if has_request
+ [ @controller.request.protocol,
+ ActionController::Base.asset_host,
+ @controller.request.relative_url_root,
+ dir, source, ext, include_host ].join
+ else
+ [ ActionController::Base.asset_host,
+ dir, source, ext, include_host ].join
+ end
ActionView::Base.computed_public_paths[cache_key] ||=
begin
@@ -400,13 +408,15 @@ def compute_public_path(source, dir, ext = nil, include_host = true)
source
else
source = "/#{dir}/#{source}" unless source[0] == ?/
- source = "#{@controller.request.relative_url_root}#{source}"
+ if has_request
+ source = "#{@controller.request.relative_url_root}#{source}"
+ end
rewrite_asset_path!(source)
if include_host
host = compute_asset_host(source)
- unless host.blank? or host =~ %r{^[-a-z]+://}
+ if has_request && !host.blank? && host !~ %r{^[-a-z]+://}
host = "#{@controller.request.protocol}#{host}"
end

0 comments on commit c240f2d

Please sign in to comment.