Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript and CSS loading twice due to Asset Pipeline

I may just be doing something wrong but all of my javascript files as well as my css files are each individually available. This would be perfect except asset pipeline also adds my applicaion.js which is making my javascript crash. Is there a way that I can tell rails not to load all the individual files, I want JUST the application.js/css files.

enter image description here

As you can see here, the search and sort bars are shown twice because the javascript is trying to run twice. Anyone else deal with this? I have seen a couple other people ask this question and have yet to see a good answer.

like image 717
Josh Avatar asked Mar 29 '12 18:03

Josh


1 Answers

IIRC this is caused by you having pre-compiled assets in public/assets, but having config.assets.compile set to true in the config for your current environment.

Normally if you're compiling assets on each request application.css and .js will only contain code that you have specifically entered into those files in app/assets, whereas if the assets have been pre-compiled (and are in public/assets) you'll see all your css and javascript in those files.

To fix this issue rm -rf public/assets and you should be good to go.

like image 70
Chris Bailey Avatar answered Sep 29 '22 14:09

Chris Bailey