Assuming there is an image file in app/assets/images/logo.png
Rails will happily find and generate the correct tag for image_tag('logo') in development mode.
However, in production mode (on Heroku, default asset pipeline / webpacker settings), image_tag('logo') will fail with an asset not present in asset pipeline error.
Correct approach is to use image_tag('logo.png') instead. Using image_tag('logo') should break or emit a warning in development.
Googling it reveals I’m not the only person falling afoul of this one:
This has bitten me in every app I’ve written since the asset pipeline was first introduced in Rails. @ferngus you should definitely file an issue for this, I couldn’t find an existing one.
I actually was investigating the issue at this moment, and the error is due to an inconsistency between manifest and environment resolvers on sprockets-rails.
The thing is though, there were already 2 issues pointing out this issue on the gem’s repo, but since nobody from the rails team said anything, I wonder now if this is by design or if there is another complication involved.
My best guess would be that Sprockets has always had overburdened maintainers. Sprocket’s original author has long since departed Rails, and the subsequent maintainers haven’t always had a huge amount of time to devote to it.
So I would guess that the issue is as simple as lack of time, and that @rafaelfranca would appreciate you taking the time to attack the problem!
Thanks!
Was hesitant to file an issue as I’m not familiar with Sprockets’s innards, didn’t know whether this had been raised before under a different guise .