From 87c57bb88f0eb1462ed31733ebcf3d9a535d8f16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 5 Oct 2011 02:17:29 +0200 Subject: Fix the lame config.action_controller.present? check scattered throughout assets_path. Conflicts: actionpack/test/template/sprockets_helper_test.rb --- actionpack/lib/sprockets/assets.rake | 7 ++++--- actionpack/lib/sprockets/helpers.rb | 3 ++- actionpack/lib/sprockets/helpers/precompile_helper.rb | 13 +++++++++++++ actionpack/lib/sprockets/helpers/rails_helper.rb | 3 --- actionpack/lib/sprockets/railtie.rb | 5 +---- 5 files changed, 20 insertions(+), 11 deletions(-) create mode 100644 actionpack/lib/sprockets/helpers/precompile_helper.rb (limited to 'actionpack/lib/sprockets') diff --git a/actionpack/lib/sprockets/assets.rake b/actionpack/lib/sprockets/assets.rake index a801050084..80c3d4d0b8 100644 --- a/actionpack/lib/sprockets/assets.rake +++ b/actionpack/lib/sprockets/assets.rake @@ -39,12 +39,13 @@ namespace :assets do config = Rails.application.config config.assets.compile = true config.assets.digest = digest unless digest.nil? - config.assets.digests = {} - env = Rails.application.assets + env = Rails.application.assets + env.context_class.send :include, ::Sprockets::Helpers::PrecompileHelper + target = File.join(Rails.public_path, config.assets.prefix) - compiler = Sprockets::StaticCompiler.new(env, + compiler = Sprockets::StaticCompiler.new(env, target, config.assets.precompile, :manifest_path => config.assets.manifest, diff --git a/actionpack/lib/sprockets/helpers.rb b/actionpack/lib/sprockets/helpers.rb index a952a55c5e..cd9c8f62e6 100644 --- a/actionpack/lib/sprockets/helpers.rb +++ b/actionpack/lib/sprockets/helpers.rb @@ -1,5 +1,6 @@ module Sprockets module Helpers - autoload :RailsHelper, "sprockets/helpers/rails_helper" + autoload :RailsHelper, "sprockets/helpers/rails_helper" + autoload :PrecompileHelper, "sprockets/helpers/precompile_helper" end end diff --git a/actionpack/lib/sprockets/helpers/precompile_helper.rb b/actionpack/lib/sprockets/helpers/precompile_helper.rb new file mode 100644 index 0000000000..ca7927f6fb --- /dev/null +++ b/actionpack/lib/sprockets/helpers/precompile_helper.rb @@ -0,0 +1,13 @@ +module Sprockets + module Helpers + module PrecompileHelper + def controller + nil + end + + def config + Rails.application.config.action_controller + end + end + end +end diff --git a/actionpack/lib/sprockets/helpers/rails_helper.rb b/actionpack/lib/sprockets/helpers/rails_helper.rb index e1d8fccf04..f866bc626e 100644 --- a/actionpack/lib/sprockets/helpers/rails_helper.rb +++ b/actionpack/lib/sprockets/helpers/rails_helper.rb @@ -8,9 +8,6 @@ module Sprockets def asset_paths @asset_paths ||= begin - config = self.config if respond_to?(:config) - config ||= Rails.application.config - controller = self.controller if respond_to?(:controller) paths = RailsHelper::AssetPaths.new(config, controller) paths.asset_environment = asset_environment paths.asset_digests = asset_digests diff --git a/actionpack/lib/sprockets/railtie.rb b/actionpack/lib/sprockets/railtie.rb index 2cf54b7777..e29612d320 100644 --- a/actionpack/lib/sprockets/railtie.rb +++ b/actionpack/lib/sprockets/railtie.rb @@ -43,10 +43,7 @@ module Sprockets ActiveSupport.on_load(:action_view) do include ::Sprockets::Helpers::RailsHelper - - app.assets.context_class.instance_eval do - include ::Sprockets::Helpers::RailsHelper - end + app.assets.context_class.send :include, ::Sprockets::Helpers::RailsHelper end end -- cgit v1.2.3