Module: ActionView::Helpers::AssetTagHelper

Defined in:
lib/asset_tag_helper.rb

Instance Method Summary collapse

Instance Method Details

#rewrite_asset_path(source, path = nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/asset_tag_helper.rb', line 5

def rewrite_asset_path(source, path = nil)
  if path && path.respond_to?(:call)
    return path.call(source)
  elsif path && path.is_a?(String)
    return path % [source]
  end

  asset_id = rails_asset_id(source)
  if asset_id.blank?
    source
  else
   # AB: As of June AWS Cloudfront supports HTTPS requests. This alternative code path should now be redundant.
    # # If the request isn't SSL, or if the request is SSL and the SSL host is set
    # if !request.ssl? || (request.ssl? && !AssetHostingWithMinimumSsl::asset_ssl_host.empty?)
    #   File.join('/', ENV['RAILS_ASSET_ID'], source)
    # else
    #   source + "?#{asset_id}"
    # end
    File.join('/', ENV['RAILS_ASSET_ID'], source)
  end
end