Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move the config bootstrapping to initialization to minimize access to…

… the Rails.application global.
  • Loading branch information...
commit 97208647ef4913d58b79aa141c1fae05b491f4bd 1 parent a223363
@chriseppstein chriseppstein authored
View
17 actionpack/lib/action_view/helpers/asset_paths.rb
@@ -109,20 +109,17 @@ def compute_asset_host(source)
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
View
8 actionpack/lib/sprockets/helpers/rails_helper.rb
@@ -11,6 +11,12 @@ def asset_paths
@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
@@ -110,7 +116,7 @@ def assets
# 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
Please sign in to comment.
Something went wrong with that request. Please try again.