How to disable default asset timestamps for some assets in rails?

There are some image objects on my site that will always remain static, and therefore you do not need to use a time stamp that is added to the images. Is there a way to not add timestamps for certain assets?

+3
source share
3 answers

Why not just use a regular HTML <img>element for these images? This will be a little faster than through the Rails helper.

+3
source

Rails docs " timestamps . , ."

ActionView::Helpers::AssetTagHelper.cache_asset_timestamps = true
+1

Solution 1 will work, except that I still need to use the host resource, and I don't want to hard code it. Solution 2 does not work, as this will affect all asset paths. I think what I should do is combine using the img tag, but use rails to calculate the resource host for me.

So, in the end it would look something like this.

<img src=\"#{@template.image_path("image.jpg}}\"/>

thanks for the idea!

+1
source

Source: https://habr.com/ru/post/1724989/


All Articles