The CSS and Javascripts in my Rails 4 app fails to load on production, but was successful in staging. The only difference between between config/environments/staging.rb
and config/environments/production.rb
is this line:
config.assets.compile = true
on staging, and
config.assets.compile = false
on production.
In both staging and production, I do rake assets:precompile
on during deployment. Yes, the fingerprinted assets are happily situated at public/assets
It is tempting to just raise my hand, cry "What the heck, I still have other things to code", and just set config.assets.compile = true on production, but as I understand this enables Live Compilation, which dynamically compiles Sass and CoffeeScripts, and I do NOT want that kind of performance tax on our live site.
However, setting config.assets.compile = false
in production does NOT generate the proper fingerprinted URL to point to the precompiled assets properly.
In staging, my application.css is happily pointed to https://staging.example.com/assets/application-8b1ca5ff4a98a7b28b0e932fe7412421.css
. Which is well and good and bliss and wonderful.
In production, it frustratingly points at https://www.example.com/stylesheets/application.css
How do I then I still use Assets Pipeline (Sprockets) without Live Compilation on production? Anybody who could help me before I run out of hair would be truly appreciated.