1

PNG Files not loading after deploy on Heroku!

I am deploying a project on Heroku, and all assets run perfectly, including images (jpgs, jpegs and gifs), but PNG files are not load! In general pages showing:

GET damainname.com/assets/namespace/my_image-867450b295e2051d381123c16c51548e.png 404 (Not Found)

Other image file extensions (JPG, JPEG and GIF) load normally.

I am using:

  • Heroku cedar (testing with and without assets:precompile locally)
  • ruby 1.9.3p448 (2013-06-27 revision 41675) [i686-linux]
  • Rails 3.2.11

production.rb:

config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
config.serve_static_assets = true
config.assets.compress = true
config.assets.compile = false
config.assets.digest = true

application.rb:

config.assets.precompile += ['application.css', 'application.js', 'admin.css', 'admin.js']
config.assets.precompile += %w[*.png *.jpg *.jpeg *.gif]
config.assets.initialize_on_precompile = false
Alexandre Magro
  • 1,131
  • 2
  • 10
  • 22

3 Answers3

4

Three things to check.

  1. Do you have a .slugingore file in your repo? If so, ensure there is not an entry in it like *.png

  2. Do you have the gem 'rails_12factor' gem in your gemfile? https://github.com/heroku/rails_12factor

  3. In your config/application.rb, set config.assets.version equal to a float higher than it currently is. Ie. increment from 1.0 to 1.1.

professormeowingtons
  • 3,504
  • 7
  • 36
  • 50
0

I've run into this before with a *.jpg - the only solution I could find was to increment config.assets.version = '1.0' in config/application.rb, forcing new assets to be generated and all old ones to expire.

CDub
  • 13,146
  • 4
  • 51
  • 68
0

I was asking answers for a similar question, then I found this entry, but if it helps in something my solution was so simple, in my project in ruby on rails gave the next error

GET http://localhost:3000/assets/images/ui-icons_555555_256x240.png 404 (Not Found)

I had in my project the images in

app/assets/images/ui-icons_555555_256x240.png

And I just make another directory named images with the png file inside

app/assets/images/images/ui-icons_555555_256x240.png

And that's all, I hope somebody help this simple solution.

Oscar Albert
  • 803
  • 8
  • 13