Heroku 没有更新 Rails 应用程序的 CSS
我在 heroku 上更新 Rails 应用程序时遇到问题。我已经启动了我的应用程序,但我尝试更改 /public/stylesheets/ 中的 application.css 文件,但每当我尝试推送到 heroku 时,CSS 都不会更改。我在本地测试了这些更改,它们工作得很好,我只是不知道如何将它们推送到 Heroku。我尝试过使用 git push heroku、heroku db:push 和 heroku rake db:migrate 进行推送,但没有任何效果。感谢您的帮助。
I'm having trouble updating my rails app on heroku. I've gotten my app up but I tried to change my application.css file in /public/stylesheets/ but whenever I try to push to heroku, the CSS never changes. I tested these changes locally and they work just fine, I just can't figure out how to push them to heroku. I've tried pushing with git push heroku, heroku db:push, and heroku rake db:migrate but nothing works. Thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
每次对 CSS 进行更改时,您都需要在终端上运行以下命令:
Each time you make changes on your CSS you need to run the following commands on the terminal:
请记住,您必须先在本地提交更改,然后才能推送它们。
如果你执行
git status
,它应该是干净的。如果不是(我的预测):
Remember that you have to commit the changes locally before you can push them.
If you do a
git status
, it should be clean.If it's not (my prediction):
就我而言,这是因为以前的开发人员已设置在本地而不是在部署时进行编译。我有一个需要删除的清单文件:
删除并推送后,heroku 就构建了我的资产。
In my case it was because a previous developer had set up to do compiles locally instead of at deploy time. I had a manifest file that I needed to delete:
Once I deleted that and pushed, heroku built my assets.
如果您最近删除了 css 文件,您还应该使用“git rm”来确保它已从您的存储库中删除。否则heroku可能仍然会使用它。
If you have recently deleted a css file, you should also use 'git rm' to ensure that it has been removed from your repository. Otherwise heroku may still use it.
恢复旧线程,但我来到这里遇到了同样的问题,所以我认为它仍然与其他人相关。检查 .css 文件是否只是由您正在测试的浏览器缓存。通过以隐身模式重新访问该站点,您将能够判断缓存文件是否掩盖了更改。
Reviving an old thread, but I got here having the same issue so I think it's still relevant to others. Check that the .css file is not simply cached by the browser you're testing on. By re-visiting the site in incognito mode you will be able to tell if a cached file is masking the changes.