Rails 4 images not loading on heroku

后端 未结 9 1648
一个人的身影
一个人的身影 2020-11-28 01:40

I have spent the better part of the day trying to get images to load on my heroku app. Everything I try works locally, but not after being deployed to heroku.

I h

9条回答
  •  伪装坚强ぢ
    2020-11-28 02:17

    I tried many solutions too but i found an invaluable solution and explanation 1. Heroku looks for assets in the public folder and that means you have to pre-compile your assets but if you were like me someone looking for a way to precompile my assets when my development environment is set to gem sqlite and production set to pg then you would do this.

    in your production.rb

    config.serve_static_assets = true
    

    if you do not have gem pg installed you need to comment it out and change your production environment to use gem sqlite and run this

    RAILS_ENV=production bundle exec rake assets:precompile
    

    when all assets have been precompiled, switch back to your default settings and git add .,commit, and push to heroku

提交回复
热议问题