Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove dependency on actionpack in ActionView::AssetPaths

Since Action View should not depend on actionpack, it's best to delegate
invalid_asset_host! to controller and just rely on such simple contract
instead of raising ActionController::RoutingError directly.
  • Loading branch information...
commit 7185e35971f4a18f48a7d67e5c86c2fcf87bdb66 1 parent 1ec1eb2
@drogus drogus authored
View
1  actionpack/lib/action_controller.rb
@@ -12,6 +12,7 @@ module ActionController
autoload :Middleware
autoload_under "metal" do
+ autoload :AssetPaths
autoload :Compatibility
autoload :ConditionalGet
autoload :Cookies
View
2  actionpack/lib/action_controller/base.rb
@@ -183,8 +183,8 @@ def self.without_modules(*modules)
MODULES = [
AbstractController::Layouts,
AbstractController::Translation,
- AbstractController::AssetPaths,
+ AssetPaths,
Helpers,
HideActions,
UrlFor,
View
15 actionpack/lib/action_controller/metal/asset_paths.rb
@@ -0,0 +1,15 @@
+require 'action_controller/metal/exceptions'
+
+module ActionController
+ module AssetPaths
+ extend ActiveSupport::Concern
+
+ included do
+ include AbstractController::AssetPaths
+ end
+
+ def invalid_asset_host!(help_message)
+ raise ActionController::RoutingError, "This asset host cannot be computed without a request in scope. #{help_message}"
+ end
+ end
+end
View
8 actionpack/lib/action_view/asset_paths.rb
@@ -1,6 +1,6 @@
require 'zlib'
require 'active_support/core_ext/file'
-require 'action_controller/metal/exceptions'
+require 'active_support/core_ext/module/delegation'
module ActionView
class AssetPaths #:nodoc:
@@ -8,6 +8,8 @@ class AssetPaths #:nodoc:
attr_reader :config, :controller
+ delegate :invalid_asset_host!, :to => :controller, :prefix => false
+
def initialize(config, controller = nil)
@config = config
@controller = controller
@@ -97,10 +99,6 @@ def default_protocol
@config.default_asset_host_protocol || (has_request? ? :request : :relative)
end
- def invalid_asset_host!(help_message)
- raise ActionController::RoutingError, "This asset host cannot be computed without a request in scope. #{help_message}"
- end
-
# Pick an asset host for this source. Returns +nil+ if no host is set,
# the host if no wildcard is set, the host interpolated with the
# numbers 0-3 if it contains <tt>%d</tt> (the number is the source hash mod 4),
Please sign in to comment.
Something went wrong with that request. Please try again.