Skip to content
This repository
Browse code

Fix sprockets warnings

Fixes #2598
  • Loading branch information...
commit 63d3809e31cc9c0ed3b2e30617310407ae614fd4 1 parent f25d65d
Joshua Peek authored August 21, 2011
9  actionpack/lib/sprockets/assets.rake
@@ -13,17 +13,20 @@ namespace :assets do
13 13
       # Ensure that action view is loaded and the appropriate sprockets hooks get executed
14 14
       ActionView::Base
15 15
 
16  
-      assets = Rails.application.config.assets.precompile
17 16
       # Always perform caching so that asset_path appends the timestamps to file references.
18 17
       Rails.application.config.action_controller.perform_caching = true
  18
+
  19
+      config = Rails.application.config
  20
+      assets = config.assets.precompile.dup
  21
+      assets << {:to => File.join(Rails.public_path, config.assets.prefix)}
19 22
       Rails.application.assets.precompile(*assets)
20 23
     end
21 24
   end
22 25
 
23 26
   desc "Remove compiled assets"
24 27
   task :clean => [:environment, 'tmp:cache:clear'] do
25  
-    assets = Rails.application.config.assets
26  
-    public_asset_path = Rails.public_path + assets.prefix
  28
+    config = Rails.application.config
  29
+    public_asset_path = File.join(Rails.public_path, config.assets.prefix)
27 30
     rm_rf public_asset_path, :secure => true
28 31
   end
29 32
 end
13  actionpack/lib/sprockets/helpers/rails_helper.rb
@@ -112,11 +112,22 @@ def asset_for(source, ext)
112 112
           asset_environment[source]
113 113
         end
114 114
 
  115
+        def digest_for(logical_path)
  116
+          if asset = asset_environment[logical_path]
  117
+            return asset.digest_path
  118
+          end
  119
+
  120
+          logical_path
  121
+        end
  122
+
115 123
         def rewrite_asset_path(source, dir)
116 124
           if source[0] == ?/
117 125
             source
118 126
           else
119  
-            asset_environment.path(source, performing_caching?, dir)
  127
+            source = digest_for(source) if performing_caching?
  128
+            source = File.join(dir, source)
  129
+            source = "/#{url}" unless source =~ /^\//
  130
+            source
120 131
           end
121 132
         end
122 133
 
5  actionpack/lib/sprockets/railtie.rb
@@ -18,9 +18,8 @@ class Railtie < ::Rails::Railtie
18 18
       require 'sprockets'
19 19
 
20 20
       app.assets = Sprockets::Environment.new(app.root.to_s) do |env|
21  
-        env.static_root = File.join(app.root.join('public'), config.assets.prefix)
22  
-        env.logger = ::Rails.logger
23  
-        env.version = ::Rails.env + "#{'-' + config.assets.version if config.assets.version.present?}"
  21
+        env.logger  = ::Rails.logger
  22
+        env.version = ::Rails.env + "-#{config.assets.version}"
24 23
 
25 24
         if config.assets.cache_store != false
26 25
           env.cache = ActiveSupport::Cache.lookup_store(config.assets.cache_store) || ::Rails.cache

0 notes on commit 63d3809

Please sign in to comment.
Something went wrong with that request. Please try again.