Heroku 没有更新 Rails 应用程序的 CSS

发布于 2024-11-07 07:27:12 字数 254 浏览 1 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

归途 2024-11-14 07:27:12

每次对 CSS 进行更改时,您都需要在终端上运行以下命令:

$bundle exec rake assets:precompile
$git add . 
$git commit -m "msg" 
$git push heroku master

Each time you make changes on your CSS you need to run the following commands on the terminal:

$bundle exec rake assets:precompile
$git add . 
$git commit -m "msg" 
$git push heroku master
烙印 2024-11-14 07:27:12

请记住,您必须先在本地提交更改,然后才能推送它们。

如果你执行git status,它应该是干净的。

如果不是(我的预测):

git commit -am "Your commit message"
git push heroku master

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):

git commit -am "Your commit message"
git push heroku master
挖个坑埋了你 2024-11-14 07:27:12

就我而言,这是因为以前的开发人员已设置在本地而不是在部署时进行编译。我有一个需要删除的清单文件:

public/assets/manifest-<md5 hash>.json

删除并推送后,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:

public/assets/manifest-<md5 hash>.json

Once I deleted that and pushed, heroku built my assets.

给妤﹃绝世温柔 2024-11-14 07:27:12

如果您最近删除了 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.

滿滿的愛 2024-11-14 07:27:12

恢复旧线程,但我来到这里遇到了同样的问题,所以我认为它仍然与其他人相关。检查 .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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文