diff options
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/sprockets/assets.rake | 10 | ||||
-rw-r--r-- | actionpack/lib/sprockets/helpers/rails_helper.rb | 4 |
2 files changed, 11 insertions, 3 deletions
diff --git a/actionpack/lib/sprockets/assets.rake b/actionpack/lib/sprockets/assets.rake index 7764bd401a..65f0ad4cc8 100644 --- a/actionpack/lib/sprockets/assets.rake +++ b/actionpack/lib/sprockets/assets.rake @@ -10,8 +10,7 @@ namespace :assets do else require "fileutils" Rake::Task["tmp:cache:clear"].invoke - Rails.application.initialize!(:assets) - Sprockets::Bootstrap.new(Rails.application).run + Rake::Task["assets:environment"].invoke unless Rails.application.config.assets.enabled raise "Cannot precompile assets if sprockets is disabled. Please set config.assets.enabled to true" @@ -40,9 +39,14 @@ namespace :assets do end desc "Remove compiled assets" - task :clean => [:environment, 'tmp:cache:clear'] do + task :clean => ['assets:environment', 'tmp:cache:clear'] do config = Rails.application.config public_asset_path = File.join(Rails.public_path, config.assets.prefix) rm_rf public_asset_path, :secure => true end + + task :environment do + Rails.application.initialize!(:assets) + Sprockets::Bootstrap.new(Rails.application).run + end end diff --git a/actionpack/lib/sprockets/helpers/rails_helper.rb b/actionpack/lib/sprockets/helpers/rails_helper.rb index 1e0e9bef77..fe37553fc1 100644 --- a/actionpack/lib/sprockets/helpers/rails_helper.rb +++ b/actionpack/lib/sprockets/helpers/rails_helper.rb @@ -60,6 +60,10 @@ module Sprockets options[:body] ? "#{path}?body=1" : path end + def path_to_image(source) + asset_paths.compute_public_path(source, asset_prefix) + end + private def debug_assets? compile_assets? && (Rails.application.config.assets.debug || params[:debug_assets]) |