Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

config.assets.precompile

View gist:1529093
1 2 3 4 5 6 7 8 9 10 11 12 13
def compile_asset?(path)
# ignores any filename that begins with '_' (e.g. sass partials)
# all other css/js/sass/image files are processed
if File.basename(path) =~ /^[^_].*\.\w+$/
puts "Compiling: #{path}"
true
else
puts "Ignoring: #{path}"
false
end
end
 
config.assets.precompile = [ method(:compile_asset?).to_proc ]
Owner

And since rake assets:precompile gives no indicator of the compilation progress, I think it great to print these Compiling and Ignoring lines.

Forgive the ignorance, but where would this method go? Inside the env file itself?

Owner

@cjohnson I put these into the production.rb

Doesn't work for me at all when deploying on heroku. I pasted in my production.rb

2012-03-29T18:19:47+00:00 app[web.1]: /app/config/environments/production.rb:27:in method': undefined methodcompile_asset?' for class Class' (NameError)
2012-03-29T18:19:47+00:00 app[web.1]: from /app/config/environments/production.rb:27:in
block in '

try putting the method in the outer scope:

 #the absolute beginning of the production.rb file
def compile_asset?(path)
  if File.basename(path) =~ /^[^_].*\.\w+$/
    puts "Compiling: #{path}"
    true
  else
    puts "Ignoring: #{path}"
    false
  end
end
SomeApplicationName::Application.configure do
   config.assets.precompile = [ method(:compile_asset?).to_proc ]
#...some other config stuff
end

Thank you! :clap:

just amazing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.