Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rails precompile Why javascript does not work locally but at heroku it works

So, the app was working great locally until I precompiled the assets. When deploying to heroku I did assets precompile and then deployed and it worked fine at heroku, but now it seems javascript got broken.

Any suggestions on how to solve it? Should I delete the files at public folder or use some configuration?

Thanks in advance

UPDATE

I get one of this for each asset file I load in development mode, is it normal?

Started GET "/assets/home.js?body=1" for 127.0.0.1 at 2012-06-15 19:16:48 +0100
Served asset /home.js - 304 Not Modified (0ms)

This is odd. I'm using twitter bootstrap and now to test if javascript is messed up I added a tooltip html example to check if it is also crashed and it actually worked.

But my dropdown at menu bar does not work. How strange is this?

like image 255
Ismael Avatar asked Jan 25 '26 20:01

Ismael


1 Answers

Finally I solved the problem.

Just changed in config/environments/development.rb

config.assets.debug = true

to

config.assets.debug = false

And now javascript works as expected

UPDATE

Now when I have this problem I actually run rake assets:clean and clean the browser cache. This will make your app work as it used to work in development work.

If you want to have a better process, you could instead create a new branch where you run precompile and keep your master branch clean.

Other alternative is to run precompile on heroku so you don't have to do it locally. I haven't tried it yet but there is a 'beta' feature you have to enable so this can work properly in all apps. You can read about it here

like image 98
Ismael Avatar answered Jan 28 '26 09:01

Ismael



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!