Created
December 28, 2011 18:38
-
-
Save iwinux/1529093 to your computer and use it in GitHub Desktop.
config.assets.precompile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ] |
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 method
compile_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 <top (required)>'
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! 👏
just amazing!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@cjohnson I put these into the
production.rb