0

The images I'm talking about is the star-half.png, star-off.png, and star-on.png located in the assets/images folder that I use for my star rating feature in my app.

In development, these images works perfectly but when I push to Heroku, the images won't load/broken. I'm already aware of using aws s3 for file uploads, but since this is just a static .png image, what is my best solution?

Currently, my solution is setting the config.assets.compile = true in production.rb but I want to know if there is a better solution?

  • Since these are assets, you don't need s3 unless you want other benefits like fast asset delivery by CDNs. you can precompile `rake assets:precompile` before deploy. – Sajan Feb 02 '17 at 10:48
  • So I will set my `config.assets.compile` back to `false` and run `rake assets:precompile` before `git push heroku`? –  Feb 02 '17 at 10:51
  • Yes, if you are precompiling. Because keeping that `true` in production will slow down the requests since sprockets will compile the assets http://stackoverflow.com/a/8827757/4587148 . – Sajan Feb 02 '17 at 10:55
  • I just set my `config.assets.compile` back to `false`, ran `git push`, ran `rake assets:precompile`, then run `git push heroku` but the images are still broken. –  Feb 02 '17 at 10:57
  • 1
    Can you check your `public/assets` folder to confirm that compiled assets are there ? also if there are compiled asset, then check the `src` of images by inspecting in browser and verify the file names are same as in `public/asset` and put that `src` url in browser and see if it shows the image. – Sajan Feb 02 '17 at 11:01
  • Yes I've checked the `public/assets` folder and the compiled assets are there. I've tried changing the path from `/assets/` to `/public/assets/` and now the images are broken in development. –  Feb 02 '17 at 11:03
  • 1
    Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/134679/discussion-between-jeramaedybohol-and-sajan). –  Feb 02 '17 at 11:05

0 Answers0