3

Found a strange bug in Ruby on Rails 4.1 asset pipeline on Heroku. All of my PNG images are not being compiled.

In Development:

image_tag('icons/example.png')
# => "/assets/icons/example-09adfasdfa7sfhpasodfuahsdas.png"

In Production on Heroku

image_tag('icons/example.png')
# => "/images/icons/example.png"

I have never run across anything like this in the asset pipeline. Any ideas as to why?

Update

As it turns out, it's not PNG images in particular. It is any image accessed via image_tag. Any images that are precompiled in CSS and Javascript point to the proper paths, but any views/helpers that use image_tag (and thus path_to_image) are pointing to the /images. I cannot tell if this has to do with the serve_static_assets configuration that Heroku recommends that is not playing well with Rails 4.1

Matt Bridges
  • 161
  • 9
  • Are you using rails_12factor gem? That usually sorts out most issues – John Beynon Mar 17 '14 at 08:53
  • I am. I also have the 'serve_static_assets' configuration set per all of the documentation on Heroku. Still no dice. – Matt Bridges Mar 17 '14 at 14:54
  • As a follow up, it turns out only PNGs in nested directories are missed on Heroku. Something like `image_tag("header.png")` compiles, but `image_tag("icons/header.png")` does not compile. – Matt Bridges Mar 19 '14 at 22:15
  • ah yes - you don't need the directory - the asset pipeline does magic when it's running in production mode. – John Beynon Mar 20 '14 at 07:13
  • The asset pipeline only flattens the directories once. Nested images normally aren't an issue in the asset pipeline. The whole purpose is to allow me to organize everything how I see fit. But here it is definitely a factor in it's failure. – Matt Bridges Mar 21 '14 at 13:57
  • Also, this does not happen when I run in production mode locally. `RAILS_ENV=production bin/rails s` after precompiling assets works like a charm. This only seems to break on Heroku. – Matt Bridges Mar 23 '14 at 20:29

0 Answers0