I can’t figure out what is causing this problem. Any ideas or suggestions greatly appreciated.
I am migrating to Rails 3.1 and everything works Ok in development. But testing a production deployment I get no assets at all… and not for the usual reason 🙂
Best I show what the main javascript include line looks like in my layout.
This line of haml:
= javascript_include_tag 'application'
In Development I get:
<script src="/assets/application.js" type="text/javascript"></script>
In Production the same line looks like:
<script src="/javascripts/all.js?1320673090" type="text/javascript"></script>
In production the include helpers are still acting like I am on 3.0. The assets compile just fine. They are in the public/assets folder (as is the manifest) and nginx serves them just fine if I point my browser to the correct url.
I have checked my Rails version on the server with bundle exec rails -v. I get back the 3.1.3 version. Also, the fact that compilation of assets on the server works as expected should indicate that things are setup “generally ok”. My production environment contains the following asset related lines:
config.serve_static_assets = false
config.assets.compress = true
config.assets.compile = false
config.assets.digest = true
config.assets.precompile << /(^[^_]|\/[^_])[^\/]*/ # from https://gist.github.com/1184843
I am guessing some Gem might be overriding the helpers but only doing it in production?
Repeating: any nudge in the right direction here would be great. Thanks in advance.
Got it.
Problem 1: I get bit by Runit every once in a while. Today was such a day.
There was a problem in config/application.rb referencing old compass fixes. Runit kept the old app running when trying to “hup” into the new one.
Mental note: Always run rails c production when in doubt.
After this the asset paths were not 3.0-style but almost. They were now /stylesheets/application.css and similar… not mention of the assets directory.
Problem 2: Sprockets needs to be required in application.rb (if not requiring rails/all). Why everything worked in development and when compiling in production, I cannot say. But adding a line to require the sprockets railtie solved this problem for me. It never entered my mind that a require could be missing since only the paths were wrong and everything else worked great. Wild guess: the local asset server in development probably requires sprockets masking that the main app is missing it.
Thanks for taking the time. Sorry to waste it for you.