How to stop Rails being 'helpful' with assets that don't have extension in Dev/Test

I have an image in my assets ‘image.png’

In dev and test, rails will happily give me a url for

image_url "image"

but the same code crashes in production unless it gets

image_url "image.png"

personally, I think it is profoundly unhelpful for dev to ‘hide’ something that will cause a crash even if all my tests pass. Is there a way I can disable this behaviour?

4 Likes

This one has caused me problems more than once. Would love to figure out how to disable this too.

1 Like

I’ve been tracking this one down and the guilty one is not Rails, but sprockets. When given a file, it actually removes the extension you gave it, then passes it to a method called resolve_under_paths, which then finds the best match given all files it has available in the pipeline.

Frankly, I don’t even know how to change this method without breaking other things. :expressionless: