Skip to content

Commit

Permalink
Fix sprockets warnings
Browse files Browse the repository at this point in the history
Fixes #2598
  • Loading branch information
josh committed Aug 21, 2011
1 parent f25d65d commit 63d3809
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
9 changes: 6 additions & 3 deletions actionpack/lib/sprockets/assets.rake
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,20 @@ namespace :assets do
# Ensure that action view is loaded and the appropriate sprockets hooks get executed
ActionView::Base

assets = Rails.application.config.assets.precompile
# Always perform caching so that asset_path appends the timestamps to file references.
Rails.application.config.action_controller.perform_caching = true

config = Rails.application.config
assets = config.assets.precompile.dup
assets << {:to => File.join(Rails.public_path, config.assets.prefix)}
Rails.application.assets.precompile(*assets)
end
end

desc "Remove compiled assets"
task :clean => [:environment, 'tmp:cache:clear'] do
assets = Rails.application.config.assets
public_asset_path = Rails.public_path + assets.prefix
config = Rails.application.config
public_asset_path = File.join(Rails.public_path, config.assets.prefix)
rm_rf public_asset_path, :secure => true
end
end
13 changes: 12 additions & 1 deletion actionpack/lib/sprockets/helpers/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,22 @@ def asset_for(source, ext)
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 = "/#{url}" unless source =~ /^\//
source
end
end

Expand Down
5 changes: 2 additions & 3 deletions actionpack/lib/sprockets/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ class Railtie < ::Rails::Railtie
require 'sprockets'

app.assets = Sprockets::Environment.new(app.root.to_s) do |env|
env.static_root = File.join(app.root.join('public'), config.assets.prefix)
env.logger = ::Rails.logger
env.version = ::Rails.env + "#{'-' + config.assets.version if config.assets.version.present?}"
env.logger = ::Rails.logger
env.version = ::Rails.env + "-#{config.assets.version}"

if config.assets.cache_store != false
env.cache = ActiveSupport::Cache.lookup_store(config.assets.cache_store) || ::Rails.cache
Expand Down

0 comments on commit 63d3809

Please sign in to comment.