[英]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.
在部署到heroku时,我做了资产预编译然后部署,并且它在heroku上工作正常,但现在看来javascript被打破了。
Any suggestions on how to solve it? 有关如何解决的任何建议? Should I delete the files at public folder or use some configuration?
我应该删除公用文件夹中的文件还是使用某些配置?
Thanks in advance 提前致谢
UPDATE 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.
我正在使用twitter bootstrap,现在测试javascript是否搞砸了我添加了一个工具提示html示例来检查它是否也崩溃了,它确实有效。
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/environments/development.rb
更改
config.assets.debug = true
to 至
config.assets.debug = false
And now javascript works as expected 现在javascript按预期工作
Now when I have this problem I actually run rake assets:clean
and clean the browser cache. 现在当我遇到这个问题时,我实际上运行了
rake assets:clean
并清理浏览器缓存。 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. 其他替代方法是在heroku上运行预编译,这样您就不必在本地执行。 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
你可以在这里阅读它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.