【问题标题】:Heroku messes up stylesHeroku 搞砸了风格
【发布时间】:2014-01-17 23:50:16
【问题描述】:
我将我的应用上传到 heroku,突然一切都变了,文本随机左右对齐,而在我自己的服务器中,就像我说的那样,它都在中间。
这是怎么回事?
链接到页面,以便您查看发生了什么:https://harjutus2.herokuapp.com
编辑:我让它在 css 文件和每个 p b 和 h2 元素中对齐,因为它无法正常工作。另外,我的链接应该是蓝色的,但它也突然消失了。
【问题讨论】:
标签:
css
ruby-on-rails
heroku
【解决方案1】:
我觉得你的风格不错!
资产
关于Heroku's handling of styles,您应该知道一些事情。在部署应用程序之前,您必须 precompile 您的资产。这样做的原因是为应用程序提供一致的感觉,并减少 Heroku dynos 的负载
设置方法如下:
#config/environments/production.rb
config.serve_static_assets = true
config.assets.compile = true
当你想部署到 Heroku 时,你只需要运行:
rake assets:precompile RAILS_ENV=production
这将预编译您的样式,让您在 Heroku 和本地保持一致