简体   繁体   English

Rails custom.css在部署到Heroku时不起作用

[英]Rails custom.css not working when deployed to Heroku

Any idea why my custom.css would work perfectly in my development environment, but not work when deployed to Heroku? 知道为什么我的custom.css在我的开发环境中可以正常工作,但是在部署到Heroku时却不能工作吗? Things that have the property display: none; 具有属性的事物显示为:none; are appearing when deployed, but are appropriately hidden when in development. 部署时会出现,但在开发中会适当隐藏。

Thanks! 谢谢!

Sounds like you are having problems with the asset pipeline. 听起来您的资产管道有问题。 Check out: 查看:

https://devcenter.heroku.com/articles/rails-asset-pipeline https://devcenter.heroku.com/articles/rails-asset-pipeline

Are you letting Heroku precompile your assets? 您要让Heroku预编译您的资产吗? Personally, I precompile all my assets before deploying to Heroku. 就个人而言,在部署到Heroku之前,我会预编译所有资产。

RAILS_ENV=production bundle exec rake assets:precompile

This will precompile all your assets and puts it under a public/assets folder. 这将预编译所有资产并将其放在public/assets文件夹下。 Then you can just add them to git and push to heroku. 然后,您可以将它们添加到git并推送到heroku。

If you do this you will be compiling manually, and you should run the precompile line before you re-deploy or update your Heroku app to catch any changes you've made in the asset pipeline. 如果这样做,则将手动进行编译,并且应在重新部署或更新Heroku应用程序之前运行预编译行,以捕获在资产管道中所做的任何更改。

You can check belows - expire browser cache. 您可以检查以下内容-过期浏览器缓存。 - check assets are deploy well. -检查资产部署是否良好。 (access to css url directly) (直接访问CSS网址)

I think that case is almost come from cache. 我认为这种情况几乎来自缓存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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