diff options
-rwxr-xr-x | actionpack/lib/action_controller/base.rb | 6 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/asset_tag_helper.rb | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index 8965ca9623..416388dfa7 100755 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -215,6 +215,12 @@ module ActionController #:nodoc: @@view_controller_internals = true cattr_accessor :view_controller_internals + # Prepends all the URL-generating helpers from AssetHelper. This makes it possible to easily move javascripts, stylesheets, + # and images to a dedicated asset server away from the main web server. Example: + # ActionController::Base.asset_host = "http://assets.example.com" + @@asset_host = "" + cattr_accessor :asset_host + # All requests are considered local by default, so everyone will be exposed to detailed debugging screens on errors. # When the application is ready to go public, this should be set to false, and the protected method <tt>local_request?</tt> # should instead be implemented in the controller to determine when debugging screens should be shown. diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb index 665674972d..ecaa12f542 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb @@ -110,7 +110,7 @@ module ActionView source = "/#{dir}/#{source}" unless source.include?("/") source = "#{source}.#{ext}" unless source.include?(".") source = "#{@request.relative_url_root}#{source}" - defined?(RAILS_ASSET_HOST) ? RAILS_ASSET_HOST + source : source + @controller.asset_host + source end end end |