I\'ve got a problem with Rails 3.1 assets pipeline. Assets are included twice in development:
This just caused me a problem. Setting the following makes the app work but includes the single application.js file - which I don't want in development:
config.serve_static_assets = false
I had pre-compiled my assets previously (seems to be the cause).
To fix it I did the following:
RAILS_ENV=development rake assets:clean
to clear out tmp/assetsIt was only after I edited application.js so it errored and then corrected it that the applciation.js included in the pages was not the full, precompiled application.js.
I'm not sure if all of those need to be done. I was also re-starting my server along the way.
Got tripped up by this (yet again), -- don't forget to add a BLANK LINE after all your //= require
directives at the end of your application.js
!
Once you get rid of /public/assets, you must also clear browser cache.
I add the same problem with less files.
Here from the documentation:
In development mode, assets are served as separate files in the order they are specified in the manifest file.
My solution was to remove the line *= require_tree .
from application.css.less
and to only use @import "my-styles";
from less.
Maybe you can find a similar solution with javascript...
Try adding the following to development.rb:
config.serve_static_assets = false
...and then clearing your browser cache (update based on comments)
The static assets refer to precompiled assets in public/assets, which is where rake assets:precompile
puts them.
What's happening is that anything that exists in public/assets will override anything in app/assets if you are serving them. So public/assets/application.js is being loaded when the js tag is intending to identifiy app/assets/application.js.