From 5371106d530e64cfb221492714fb7cef32fa45c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hubert=20=C5=81=C4=99picki?= Date: Thu, 8 May 2014 08:05:45 +0200 Subject: Allow custom asset host to be passed in asset_url --- actionview/lib/action_view/helpers/asset_url_helper.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'actionview/lib/action_view/helpers/asset_url_helper.rb') diff --git a/actionview/lib/action_view/helpers/asset_url_helper.rb b/actionview/lib/action_view/helpers/asset_url_helper.rb index 41997a85b3..86a84c1356 100644 --- a/actionview/lib/action_view/helpers/asset_url_helper.rb +++ b/actionview/lib/action_view/helpers/asset_url_helper.rb @@ -191,7 +191,8 @@ module ActionView # (proc or otherwise). def compute_asset_host(source = "", options = {}) request = self.request if respond_to?(:request) - host = config.asset_host if defined? config.asset_host + host = options[:host] + host ||= config.asset_host if defined? config.asset_host host ||= request.base_url if request && options[:protocol] == :request if host.respond_to?(:call) -- cgit v1.2.3 From db9a5c5a1f8e2a1590f0ac9436587d58a67a629e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hubert=20=C5=81=C4=99picki?= Date: Thu, 8 May 2014 13:35:31 +0200 Subject: Improve documentation for asset_url Updated CHANGELOG.md with entry about :host in asset_url --- actionview/lib/action_view/helpers/asset_url_helper.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'actionview/lib/action_view/helpers/asset_url_helper.rb') diff --git a/actionview/lib/action_view/helpers/asset_url_helper.rb b/actionview/lib/action_view/helpers/asset_url_helper.rb index 86a84c1356..ae684af87b 100644 --- a/actionview/lib/action_view/helpers/asset_url_helper.rb +++ b/actionview/lib/action_view/helpers/asset_url_helper.rb @@ -147,7 +147,14 @@ module ActionView # 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. + # 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/application.js + # asset_url "application.js", host: "http://cdn.example.com" # => http://cdn.example.com/javascripts/application.js + # def asset_url(source, options = {}) path_to_asset(source, options.merge(:protocol => :request)) end -- cgit v1.2.3