diff options
author | Chris Eppstein <chris@eppsteins.net> | 2011-06-18 12:10:09 -0700 |
---|---|---|
committer | Chris Eppstein <chris@eppsteins.net> | 2011-06-27 13:55:10 -0700 |
commit | 2cc1bc37732a5f89c8364e6724e8c39e14216a0a (patch) | |
tree | 5603640417c12b75b8baad66b8b5c5ed9af1d893 /actionpack | |
parent | 6c64e1e3a33c2e703a9939f075fb57167b75b36a (diff) | |
download | rails-2cc1bc37732a5f89c8364e6724e8c39e14216a0a.tar.gz rails-2cc1bc37732a5f89c8364e6724e8c39e14216a0a.tar.bz2 rails-2cc1bc37732a5f89c8364e6724e8c39e14216a0a.zip |
Move the config bootstrapping to initialization to minimize access to the Rails.application global.
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_view/asset_paths.rb | 17 | ||||
-rw-r--r-- | actionpack/lib/sprockets/helpers/rails_helper.rb | 8 |
2 files changed, 14 insertions, 11 deletions
diff --git a/actionpack/lib/action_view/asset_paths.rb b/actionpack/lib/action_view/asset_paths.rb index a74d45db6f..a768a0b882 100644 --- a/actionpack/lib/action_view/asset_paths.rb +++ b/actionpack/lib/action_view/asset_paths.rb @@ -107,20 +107,17 @@ module ActionView end def relative_url_root - if controller.respond_to?(:config) && controller.config - controller.config.relative_url_root - elsif config.respond_to?(:action_controller) && config.action_controller - config.action_controller.relative_url_root - elsif Rails.respond_to?(:application) && Rails.application.config - Rails.application.config.action_controller.relative_url_root - end + config = controller.config if controller.respond_to?(:config) + config ||= config.action_controller if config.action_controller.present? + config ||= config + config.relative_url_root end def asset_host_config - if config.respond_to?(:asset_host) + if config.action_controller.present? + config.action_controller.asset_host + else config.asset_host - elsif Rails.respond_to?(:application) - Rails.application.config.action_controller.asset_host end end diff --git a/actionpack/lib/sprockets/helpers/rails_helper.rb b/actionpack/lib/sprockets/helpers/rails_helper.rb index 3a77db5fd8..cf185749ea 100644 --- a/actionpack/lib/sprockets/helpers/rails_helper.rb +++ b/actionpack/lib/sprockets/helpers/rails_helper.rb @@ -10,6 +10,12 @@ module Sprockets @asset_paths ||= begin config = self.config if respond_to?(:config) controller = self.controller if respond_to?(:controller) + config ||= Rails.application.config + if config.action_controller.present? + config.action_controller.default_asset_host_protocol ||= :relative + else + config.default_asset_host_protocol ||= :relative + end RailsHelper::AssetPaths.new(config, controller) end end @@ -109,7 +115,7 @@ module Sprockets # When included in Sprockets::Context, we need to ask the top-level config as the controller is not available def performing_caching? - @config ? @config.perform_caching : Rails.application.config.action_controller.perform_caching + config.action_controller.present? ? config.action_controller.perform_caching : config.perform_caching end end end |