CSS在heroku看起来不同 [英] CSS is looking different on heroku
问题描述
正如你应该在下面的图片中看到的,我的本地主机站点上的css在顶部比在heroku上更好地隔开。
以前有人有这种类型的问题。您可以在此页面上查看最佳
我通过在我的计算机上本地预编译资源,然后将它们推送到Heroku来修复我的应用程序中的问题。
预编译资产:
RAILS_ENV = rake assets:precompile
将更改添加/提交到git存储库:
git add public / assets
$ p $为了安全我测试了整个事情在我的机器上的本地分支,我推送到Heroku使用以下命令(Heroku通常忽略除主分支之外的所有分支,因此窍门):
git commit -mvendor compiled assets
git push -f heroku heroku-assetpipeline:master
As you should see in the images below, the css on my local host site is spaced much better at the top than it is on heroku.
Has anyone had this type of problem before. You can see it best on this page http://pltcpal.herokuapp.com/forums/
I'm using Twitter bootstrap, which recommends adding
`padding-top: 40px;`
to body if using the top nav bar. Somehow it's not working...
解决方案The problem is related to the handling of the asset pipeline on Heroku. There are several ways on how this can be handled, see http://devcenter.heroku.com/articles/rails31_heroku_cedar
I fixed the issue in my application by pre-compiling the assets locally on my machine and then pushing them to Heroku.
Pre-compile the assets:
RAILS_ENV=production bundle exec rake assets:precompile
Add/commit the changes to git repository:
git add public/assets git commit -m "vendor compiled assets"
To be safe I tested the whole thing on a local branch on my machine first which I pushed to Heroku using the following command (Heroku normally ignores all branches except the master branch, thus the trick):
git push -f heroku heroku-assetpipeline:master
这篇关于CSS在heroku看起来不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!