From 5ac9b530fed8285ca33faf251edfcf3dca3a742a Mon Sep 17 00:00:00 2001 From: Mark Moser Date: Fri, 16 Sep 2016 12:57:24 -0500 Subject: [PATCH] inlined mailer template images completes #81 --- app/mailers/application_mailer.rb | 15 +++++++++++++++ app/views/layouts/mailer.html.inky | 6 +++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 6f7e596..ec06647 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -2,4 +2,19 @@ class ApplicationMailer < ActionMailer::Base default from: ENV['default_mail_from'] layout 'mailer' + + before_action :inline_layout_images + + private + + def inline_layout_images + # inline images requested in default mailer layout + attachments.inline['perficientdigital-logo.jpg'] = image_file('perficientdigital-logo.jpg') + attachments.inline['yellowslant-left.jpg'] = image_file('yellowslant-left.jpg') + attachments.inline['yellowslant-right.jpg'] = image_file('yellowslant-right.jpg') + end + + def image_file image + File.read(Rails.root.to_s + "/app/assets/images/#{image}") + end end diff --git a/app/views/layouts/mailer.html.inky b/app/views/layouts/mailer.html.inky index 2969c38..12f03c3 100644 --- a/app/views/layouts/mailer.html.inky +++ b/app/views/layouts/mailer.html.inky @@ -26,7 +26,7 @@ ©2016 All Rights Reserved - Perficient Digital - <%= image_tag("perficientdigital-logo.jpg", alt:"Perficient Digital") %> + <%= image_tag(attachments["perficientdigital-logo.jpg"].url, alt:"Perficient Digital") %> @@ -37,13 +37,13 @@
- <%= image_tag("yellowslant-left.jpg", alt:"Perficient Digital") %> + <%= image_tag(attachments["yellowslant-left.jpg"].url, alt:"Perficient Digital") %> - <%= image_tag("yellowslant-right.jpg", alt:"Perficient Digital") %> + <%= image_tag(attachments["yellowslant-right.jpg"].url, alt:"Perficient Digital") %>