【问题标题】:Image is showing status=404 after deploying application to Heroku将应用程序部署到 Heroku 后,图像显示 status=404
【发布时间】:2017-12-19 13:54:03
【问题描述】:

我将我的应用程序部署到 Heroku,但一旦我这样做了,图像就没有出现。我查看了 Heroku 日志文件,它为该图像提供了 status=404。当我在我的 mac book 上运行它时,图像会出现在本地。 错误信息是:

 2017-12-19T13:42:42.487011+00:00 heroku[router]: at=info method=GET 
 path="/images/MyPhoto.jpeg" host=bk-devcamp-portfolio.herokuapp.com 
 request_id=970163c2-4d3a-4b9a-83e0-7204b7cf4f10 fwd="66.194.42.54" 
 dyno=web.1 connect=2ms service=5ms status=404 bytes=1902 protocol=https

 2017-12-19T13:42:42.430206+00:00 heroku[router]: at=info method=GET 
 path="/about-me" host=bk-devcamp-portfolio.herokuapp.com 
 request_id=4aebf34c-b6f9-47c3-a678-b779a7efa1ed fwd="66.194.42.54" 
 dyno=web.1 connect=1ms service=32ms status=200 bytes=11732 protocol=https

【问题讨论】:

    标签: heroku ruby-on-rails-5


    【解决方案1】:

    heroku 描述了如何修复资产预编译问题:Heroku Assets

    修复 1)

    RAILS_ENV=production bundle exec rake assets:precompile
    

    修复 2) 在“config/application.rb”中添加这一行:

    config.serve_static_assets = true
    

    或者,您可以通过包含

    来获得相同的结果

    rails_12factor Gemfile 中的 gem:

    gem 'rails_12factor', group: :production
    

    【讨论】:

      猜你喜欢
      • 2016-03-03
      • 1970-01-01
      • 1970-01-01
      • 2014-07-30
      • 1970-01-01
      • 1970-01-01
      • 2022-07-30
      • 2012-07-16
      相关资源
      最近更新 更多