sprockets-rails
sprockets-rails copied to clipboard
image_url different performance on development & production
with twitter_card.png under app/assets/images
When I render image path with image_url('twitter_card')
on production environment, it produce: http://localhost:3000/images/twitter_card
while on development environment is http://localhost:3000/assets/twitter_card-db51e42973995bd4864955be0a949040f6c453b57ac692bd7e0fd4b9871b74f3.png
As a control group:
When I render image path with image_url('twitter_card.png')
Both development & production environment are produce: http://localhost:3000/assets/twitter_card-db51e42973995bd4864955be0a949040f6c453b57ac692bd7e0fd4b9871b74f3.png
It's so good to auto detect the correct image on development. But if somebody careless like me, it will find the different performance and spend much time to find out what happened.
If possible, keep the same under development & production, it will reduce unwished surprise. 😆
Environment: Ruby 2.3.0 Rails 4.2.6 sprockets-rails 3.0.4 sprockets 3.5.2
I believe this is expected behavior. If you want parity between dev/prod you'll want to change the config/development.rb to use config.assets.digest = true if I remember correctly.
Actually this is a bug. The problem is that in development we are serving the assets when the extension is not set. You need to set the extension to get it working, and we should not serve the image in development if it is not specified.
Yes, use image without extension is not a good practise. It's better if we can find the fault in development as soon as possible.