Image tag does not include resource digest via email

I have a Rails 4 application that sends some HTML emails. Letters contain an image in the footer, but it’s hard for me to find it in the workplace. I looked through stackoverflow for a few answers on this, and everyone says

1 - add config.action_mailer.asset_host = "http://example.com"

2 - use a helper method image_tagfor rendering images

So i did it

#config/environments/production.rb
...
config.action_mailer.asset_host = "http://example.com"

#app/views/app_mailer/layout/dark.html.erb
...
<%= image_tag "dark/footer.png", style: "border: 0;", alt: "footer" %>

However, the generated src tag does not take into account the digest sent to the image name as soon as I preassemble the assets.

In my letter I get src="http://example.com/assets/dark/footer.png"

and in my application I have public/assets/dark/footer-e2f622dcfd3016d12ec655bcfe81ec3d.png

therefore, the image is not displayed properly.

Am I missing something here?

Thank.

+4
1

. , , , , :

<%= image_tag "path_to_image.png" %>

:

%img{src=image_url("path_to_image.png")}
0

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


All Articles