aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2012-08-11 15:14:42 +0200
committerPiotr Sarnacki <drogus@gmail.com>2012-08-28 10:51:03 +0200
commit7185e35971f4a18f48a7d67e5c86c2fcf87bdb66 (patch)
treeb4a66a624ce1faa430afd51ad21a988d4d16fe63 /actionpack
parent1ec1eb2ff2ad5de70db7a632b93641a06a623a42 (diff)
downloadrails-7185e35971f4a18f48a7d67e5c86c2fcf87bdb66.tar.gz
rails-7185e35971f4a18f48a7d67e5c86c2fcf87bdb66.tar.bz2
rails-7185e35971f4a18f48a7d67e5c86c2fcf87bdb66.zip
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.
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller.rb1
-rw-r--r--actionpack/lib/action_controller/base.rb2
-rw-r--r--actionpack/lib/action_controller/metal/asset_paths.rb15
-rw-r--r--actionpack/lib/action_view/asset_paths.rb8
4 files changed, 20 insertions, 6 deletions
diff --git a/actionpack/lib/action_controller.rb b/actionpack/lib/action_controller.rb
index 31df9d605c..153e13f2db 100644
--- a/actionpack/lib/action_controller.rb
+++ b/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
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index f829f5e8a2..0d79e046a1 100644
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -183,8 +183,8 @@ module ActionController
MODULES = [
AbstractController::Layouts,
AbstractController::Translation,
- AbstractController::AssetPaths,
+ AssetPaths,
Helpers,
HideActions,
UrlFor,
diff --git a/actionpack/lib/action_controller/metal/asset_paths.rb b/actionpack/lib/action_controller/metal/asset_paths.rb
new file mode 100644
index 0000000000..5165814dfe
--- /dev/null
+++ b/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
diff --git a/actionpack/lib/action_view/asset_paths.rb b/actionpack/lib/action_view/asset_paths.rb
index 81880d17ea..3ddd8bd552 100644
--- a/actionpack/lib/action_view/asset_paths.rb
+++ b/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 @@ module ActionView
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 @@ module ActionView
@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),