Skip to content

Instantly share code, notes, and snippets.

@leonid-shevtsov
Created December 10, 2011 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leonid-shevtsov/1455766 to your computer and use it in GitHub Desktop.
Save leonid-shevtsov/1455766 to your computer and use it in GitHub Desktop.
PRECOMPILE ALL THE ASSETS!
# This snippet adds any and all CSS and JS files in asset directories to list of precompiled assets.
# Avoid the dreaded 'whatever.js isn't precompiled' error
config.assets.precompile += Dir['app/assets/stylesheets/**/*.css'].map{|f| f.gsub('app/assets/stylesheets/','')}
config.assets.precompile += Dir['app/assets/javascripts/**/*.js'].map{|f| f.gsub('app/assets/javascripts/','')}
@kirs
Copy link

kirs commented Dec 10, 2011

Why do you need to do this? In my opinion, it's very bad practice. It's better to disable Asset Pipeline at all, if you want to have access to all your assets directly.

@leonid-shevtsov
Copy link
Author

I never said it's a good practice.

@kirs
Copy link

kirs commented Dec 10, 2011

Succinctly :)

@leonid-shevtsov
Copy link
Author

To put this into perspective, the code was used to hotfix a project upgraded to 3.1 when it started to throw up precompilation errors in production.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment