instance method
asset_path
Ruby on Rails 4.1.16
Since v4.0.13Signature
asset_path(source, options = {})
Computes the path to asset in public directory. If :type options is set, a file extension will be appended and scoped to the corresponding public directory.
All other asset *_path helpers delegate through this method.
asset_path "application.js" # => /application.js asset_path "application", type: :javascript # => /javascripts/application.js asset_path "application", type: :stylesheet # => /stylesheets/application.css asset_path "http://www.example.com/js/xmlhr.js" # => http://www.example.com/js/xmlhr.js
Parameters
-
sourcereq -
optionsopt = {}
Source
# File actionview/lib/action_view/helpers/asset_url_helper.rb, line 120
def asset_path(source, options = {})
source = source.to_s
return "" unless source.present?
return source if source =~ URI_REGEXP
tail, source = source[/([\?#].+)$/], source.sub(/([\?#].+)$/, '')
if extname = compute_asset_extname(source, options)
source = "#{source}#{extname}"
end
if source[0] != ?/
source = compute_asset_path(source, options)
end
relative_url_root = defined?(config.relative_url_root) && config.relative_url_root
if relative_url_root
source = File.join(relative_url_root, source) unless source.starts_with?("#{relative_url_root}/")
end
if host = compute_asset_host(source, options)
source = File.join(host, source)
end
"#{source}#{tail}"
end
Defined in actionview/lib/action_view/helpers/asset_url_helper.rb line 120
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionView::Helpers::AssetUrlHelper