running rails app on heroku, can't see static pages in /public folder

前端 未结 3 1263
囚心锁ツ
囚心锁ツ 2020-12-17 16:56

I have a couple static pages which when running locally work as localhost:3000/foo.html, but this doesn\'t work once uploaded to heroku.

I tried adding the following

相关标签:
3条回答
  • 2020-12-17 17:13

    Per this article, you will need to tell Rails to serve static assets itself with:

    config.serve_static_assets = true
    

    in your config/environments/production.rb

    0 讨论(0)
  • 2020-12-17 17:13

    This baffled me for hours, but here's another potential solution. For some reason, I could generate documentation into /public/docs, but the documentation would not load, even immediately after I generated it. I would run a Heroku bash console, generate the documentation, exit, then re-run Heroku bash only to find that /public no longer contained my docs folder.

    So, the only solution I found was to include the documentation in the Git repository. That was the only way that Heroku persisted /public/docs across deploys and bash instances.

    I have no idea why this is... I opened a support ticket with Heroku and am awaiting a response.

    0 讨论(0)
  • 2020-12-17 17:25

    Alternatively you can add the rails_12factor gem to the production group:

    gem 'rails_12factor', group: :production
    

    according to Heroku. This will also redirect log to stdout as also required by Heroku.

    0 讨论(0)
提交回复
热议问题