Missing images cause routing errors?

Dear folks. I recently discovered that I get nasty RoutingError
exceptions any time I refer to an image that doesn’t exist (whether I
use an html img tag or an image_tag helper). Now obviously, I
shouldn’t be pointing to missing images, but it’s going to happen on
occasion. As far as I could tell from the helper documentation, Rails
doesn’t confirm the existence of assets before linking to them, so I
didn’t expect such an ungracious bombing in the case of missing
images. Are there underlying routes that handle the loading of images,
that can perhaps be suppressed in the case of missing files? Does
anyone have any input on this? Cheers.

On Apr 16, 9:57 am, Yuval [email protected] wrote:

Dear folks. I recently discovered that I get nasty RoutingError
exceptions any time I refer to an image that doesn’t exist (whether I
use an html img tag or an image_tag helper). Now obviously, I
shouldn’t be pointing to missing images, but it’s going to happen on
occasion. As far as I could tell from the helper documentation, Rails
doesn’t confirm the existence of assets before linking to them, so I
didn’t expect such an ungracious bombing in the case of missing
images. Are there underlying routes that handle the loading of images,
that can perhaps be suppressed in the case of missing files? Does
anyone have any input on this? Cheers.

You can modify your routes.rb so that if Apache can’t find the image,
routes it to rails, and of course the route isn’t in any controllers,
to return some “Image not Found” gif via a method in application.rb.
Especially if you have a consistent directory where you keep all those
images, you can make this route very specific, and still catch “real”
routing errors.