【问题标题】:Heroku css not loading after assets:precompile资产后未加载 Heroku css:预编译
【发布时间】:2013-10-30 23:34:22
【问题描述】:

Heroku 突然停止工作并给了我这个错误:

  could not connect to server: Connection refused
  Is the server running on host "127.0.0.1" and accepting
  Precompiling assets failed.

经过一番研究,我跑了这条线:

 running RAILS_ENV=production bundle exec rake assets:precompile

这有效,但现在当我将更新推送到 heroku 时,新的 css 不会加载。 此行以前从未显示过:

Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment

如果可能的话,您能否解释一下为什么 assets:precompile 行解决了我原来的问题?

【问题讨论】:

  • 阅读:guides.rubyonrails.org/asset_pipeline.html#precompiling-assets 这将回答您为什么应该预编译资产的问题。但是该特定命令使用exec 命令在生产模式下运行它。此外,当您说新的 CSS 不会更新您得到的控制台中的错误时。发布这个
  • 感谢您的链接,它帮助我更了解它。推送到heroku时没有错误,只是没有加载任何新的css。
  • 当您尝试加载页面时,打开 firebug 或 chrome 开发工具并转到控制台。你应该有某种输出
  • 嗯,chrome 开发者控制台只显示了一些关于字体的信息。

标签: ruby-on-rails heroku ruby-on-rails-4


【解决方案1】:

运行以下命令:

 bundle exec rake tmp:clear

 bundle exec rake assets:clean RAILS_ENV=production

 bundle exec rake assets:precompile RAILS_ENV=production

希望这会有所帮助!

【讨论】:

  • 只需要 bundle exec rake assets:clean RAILS_ENV=production 就可以了。感谢您的帮助!
猜你喜欢
  • 1970-01-01
  • 2013-08-30
  • 2012-04-07
  • 1970-01-01
  • 2016-10-26
  • 1970-01-01
  • 2020-01-20
  • 2015-08-28
  • 1970-01-01
相关资源
最近更新 更多