So, I've learned how to avoid it. But don't know why it happens however.
In development mode, assets are served as separate files in the order they are specified in the manifest file. This manifest:
//= require core
//= require projects
//= require tickets
would generate this HTML, three require
- three separate tags:
<script src="/assets/core.js?body=1" type="text/javascript"></script>
<script src="/assets/projects.js?body=1" type="text/javascript"></script>
<script src="/assets/tickets.js?body=1" type="text/javascript"></script>
But Sprocket with concatenation is not a Sprocket without concatenation (the one as above). If you want to concatenate files you have to turn debug mode off:
config.assets.debug = false
When debug mode is off, Sprockets concatenates and runs the necessary preprocessors on all files. With debug mode turned off the manifest above would generate instead:
<script src="/assets/application.js" type="text/javascript"></script>
Three separate files now are in one.
SOLUTION:
So I tried
config.assets.debug = false
// and then
rake assets:precompile:all RAILS_ENV=development
and the error disappeared.
I think the reason is in the sequence of files. With debug = true
precompilation loses right sequence of files in spite of the fact that the right sequence is denoted in my manifest (which is nothing more then a simple js file, somefile.js
, that you add to your page; they just call it manifest).