Rails 4 images not loading on heroku

后端 未结 9 1645
一个人的身影
一个人的身影 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:19

    Rails ('4.1.5') I had a similar issue of images not showing on Heroku but showing up locally. I am not using paperclip or carrierwave gems, I precompile locally and also using RAILS_ENV=production I push to github and it deploys fine to Heroku.

    I solved the issue by having:

    config.serve_static_assets = true
    config.assets.compile = true
    config.assets.js_compressor = :uglifier
    config.assets.digest = true
    
    // delete precompiled assets
    bundle exec rake assets:clobber --trace
    RAIL_ENV=production bundle exec rake assets:clobber --trace
    

    copied images to public/assets from app/assets. then:

    // tests should pass
    bundle exec rake assets:precompile --trace
    RAILS_ENV=production bundle exec rake assets:precompile --trace
    
    git commit
    git push
    

    And it was running fine on Heroku.

提交回复
热议问题