Sig
Sig

Reputation: 5986

image tag does not include asset digest on email

I have a Rails 4 app that sends out some HTML emails. The emails contains an image in the footer but I have an hard time to properly render it on production. I have looked on stackoverflow several answers about this topic and everyone says

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

2 - to use the helper method image_tag to render the images

So I have done that

#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 doesn't take in consideration the digest postfixed to the image name once I precompile the assets.

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

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

so the image is not properly rendered.

Am I missing anything here?

Thanks.

Upvotes: 4

Views: 634

Answers (1)

jesusgonzalezrivera
jesusgonzalezrivera

Reputation: 385

I had the same problem with a project. We finally achieve to show the pictures on the email, changing this:

<%= image_tag "path_to_image.png" %>

To this:

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

Upvotes: 0

Related Questions