Skip to content

@iwinux /gist:1529093
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
config.assets.precompile
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 ]
@iwinux
Owner

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

@wchrisjohnson

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

@iwinux
Owner

@cjohnson I put these into the production.rb

@bkempner

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 '

@logical42

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
@swrobel

Thank you! :clap:

@okliv

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.