简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM