I want to test my emails in dev mode, but I can't get the images to show.
In my mailer view, I call them this way:
<%= image_tag("how-icon-3.png", width: "101", border: "0", style: "display: block; width: 101px;", alt: "Decorissimo - Como 1") %>
I've also tried with
<%= image_tag("/assets/how-icon-1.png", border: "0", style: "display: block; width: 101px;", alt: "Decorissimo - Como 1") %></a>
and with
<table border="0" width="100%" cellpadding="0" cellspacing="0" bgcolor="dce0ec" style="background: url(<%= image_path('/mailers/user_bg.jpg') %>); background-size: cover; background-position: top center; background-repeat: no-repeat;" class="main-bg">
None of them show, and they get printed in the HTML like this:
<img alt="Decorissimo - Como 1" border="0" src="//localhost:3000/assets/how-icon-1.png" style="display: block; width: 101px;">
I have configured in development.rb:
config.action_mailer.asset_host = 'localhost:3000'
What am I missing?
Thanks
The tag that you've added image_tag('/assets...')
combined with localhost:3000
set as the asset_host
would mean that all of your assets/images in the email are along the lines of:
http://localhost:3000/assets/how-icon-3.png
This won't ever render in an email as there is no way for your email application to render something from localhost:3000 (no access to it).
On a production server, my sense is that you'd have asset_host
be a real URL that is resolvable across the web (i.e., http://example.com/assets/etc
).
For development, you can use a gem like MailCatcher to capture your emails locally and view the images, etc.
Hope this helps!