I have a problem with rails 4.1.6. Preview email program.
I want to see attached images in preview mode, but this does not work. I find it wrong
There is my code:
Mail file
class AppMailer < ActionMailer::Base default from: "robot@mysite.com" # AppMailer.test_mail.deliver def test_mail attachments.inline['rails.png'] = File.read(Rails.root.join('app', 'assets', 'images', 'rails.png')) mail( to: 'my-email@gmail.com', subject: "test letter", template_path: "mailers", template_name: "test" ) end end
Preview file
class MailerPreview < ActionMailer::Preview def app_mailer AppMailer.test_mail end end
Template file
%p Hello, World! %p= image_tag attachments['rails.png'].url
When will I go to
/rails/mailers/mailer/app_mailer
I see a preview page, but the images do not work. Html code output
<p>Hello, World!</p> <p><img src="cid:544d1354a8aa0_fda8082dbf8258ca@admins-air.mail"></p>
So. I think I need to find a way to get the path / in / file instead of CID in preview mode
(When I sent a letter to my inbox - the letter looks fine)
What am I doing wrong in preview mode?
ruby-on-rails ruby-on-rails-4 actionmailer
the-teacher Oct 26 '14 at 15:46 2014-10-26 15:46
source share