Method: ActionView::Helpers::AssetUrlHelper#asset_url

Defined in:
actionview/lib/action_view/helpers/asset_url_helper.rb

#asset_url(source, options = {}) ⇒ Object Also known as: url_to_asset

Computes the full URL to an asset in the public directory. This will use asset_path internally, so most of their behaviors will be the same. If :host options is set, it overwrites global config.action_controller.asset_host setting.

All other options provided are forwarded to asset_path call.

asset_url "application.js"                                 # => http://example.com/assets/application.js
asset_url "application.js", host: "http://cdn.example.com" # => http://cdn.example.com/assets/application.js


231
232
233
# File 'actionview/lib/action_view/helpers/asset_url_helper.rb', line 231

def asset_url(source, options = {})
  path_to_asset(source, options.merge(protocol: :request))
end