diff options
Diffstat (limited to 'actionpack/lib/sprockets/helpers')
-rw-r--r-- | actionpack/lib/sprockets/helpers/rails_helper.rb | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/actionpack/lib/sprockets/helpers/rails_helper.rb b/actionpack/lib/sprockets/helpers/rails_helper.rb index ec3d36d5ad..4fb8d0af37 100644 --- a/actionpack/lib/sprockets/helpers/rails_helper.rb +++ b/actionpack/lib/sprockets/helpers/rails_helper.rb @@ -71,9 +71,8 @@ module Sprockets private def debug_assets? params[:debug_assets] == '1' || - params[:debug_assets] == 'true' - rescue NoMethodError - false + params[:debug_assets] == 'true' || + Rails.application.config.assets.debug end # Override to specify an alternative prefix for asset path generation. @@ -112,11 +111,22 @@ module Sprockets asset_environment[source] end + def digest_for(logical_path) + if asset = asset_environment[logical_path] + return asset.digest_path + end + + logical_path + end + def rewrite_asset_path(source, dir) if source[0] == ?/ source else - asset_environment.path(source, performing_caching?, dir) + source = digest_for(source) if performing_caching? + source = File.join(dir, source) + source = "/#{source}" unless source =~ /^\// + source end end @@ -128,9 +138,14 @@ module Sprockets end end - # When included in Sprockets::Context, we need to ask the top-level config as the controller is not available def performing_caching? - config.action_controller.present? ? config.action_controller.perform_caching : config.perform_caching + # When included in Sprockets::Context, we need to ask the + # top-level config as the controller is not available. + if config.action_controller.present? + config.action_controller.perform_caching + else + config.perform_caching + end end end end |