1

So my company updated Rails and Ruby versions, after that only few images became broken. They all defined in scss with image_url("frontend/image_title.png"), but only like 4 of them aren't showing anymore, server gives 404 error. All of them used as a background images.

What could be a problem and a solution?

Alex K
  • 173
  • 2
  • 13

2 Answers2

1

Have you tried precompiling the assets ?

The call too image_url is done once during precompilation of assets so it could be that the assets in production still have old paths.

To precompile run the following command:

bundle exec rake assets:precompile
  • Yes, we always do ```assets:clobber``` and ```assets:precompile```, but only those 4 images are 404'ed. – Alex K Jan 22 '18 at 12:38
  • What is the full path in the markup/asset when you inspect it in the browser ? – Peter Lehwess Jan 22 '18 at 12:46
  • One more thing I suggest looking here if you haven't already seen it. It is pretty compressive and covers most areas to check. https://stackoverflow.com/questions/21650699/rails4-image-url-not-generating-digest-in-scss – Peter Lehwess Jan 22 '18 at 12:53
  • In browser it looks for assets at my site, like ```mysite.com/assets/etc```, but it should look at the amazon bucket, like all the other images works, except for those. – Alex K Jan 22 '18 at 12:58
0

Looks like i will always answer my own questions :)

The problem was that there are few .scss files that was compiling with assets pipeline, and those .scss files had some same code, like scss variables and reset code, which i decided to move out of them to separate file, called reset.css.scss and import that file into those .scss files with @import function, which works bad with Rails *= require methods.

After moving that code back to .scss files and removing the @import stuff, everything worked fine.

Alex K
  • 173
  • 2
  • 13
  • actually it appears again now when another person doing assets clobbering and compilation, so question is still open :( – Alex K Jan 30 '18 at 14:13