Question

I have a rails 4 app on heroku, and I want to embed some of my image assets in a static website that I'm making.

The problem is that rails adds a digest to the asset path.

<img src="http://myapp.herokuapp.com/assets/tools/my-image-43b65377b7644fae3f34d288f3235b80.png"/>

This makes it very hard for me to hotlink to my assets, because their digests may change over time.

Is there anyway to embed my images without having to insert this digest? I know that rails 3.1 allowed you to do so.

Was it helpful?

Solution

In rails-4, non digested assets are not generated anymore.

If you want to hotlink assets, place a copy of image you'll use in public/. To avoid duplication, you can use a symlink pointing to the proper location in app/assets/images/.

It's worth noting that rails does a very good job at caching images in browser, and it is usually recommended to add far future timeout for assets caching in front server. So you should probably avoid to hotlink images that are prone to change often.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top