Josh
Josh

Reputation: 5721

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.

Upvotes: 8

Views: 3303

Answers (1)

Chris Bailey
Chris Bailey

Reputation: 4136

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.

Upvotes: 12

Related Questions