Skip to content

Commit

Permalink
don't die on sending emails for picture sets without combined image
Browse files Browse the repository at this point in the history
  • Loading branch information
digitaltom committed Jun 8, 2018
1 parent 1d30bdb commit 606d5cd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion app/mailers/picture_set_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ class PictureSetMailer < ApplicationMailer

def image_email(email, picture_set)
attachments.inline['animation.gif'] = File.read(File.join(picture_set[:full_path], picture_set[:animation]))
attachments.inline['combined.jpg'] = File.read(File.join(picture_set[:full_path], picture_set[:combined]))
if File.exist?(File.join(picture_set[:full_path], picture_set[:combined]))
attachments.inline['combined.jpg'] = File.read(File.join(picture_set[:full_path], picture_set[:combined]))
end
mail(to: email, subject: "Your Photobox picture from '#{OPTS.image_caption}'")
end
end
7 changes: 4 additions & 3 deletions app/views/picture_set_mailer/image_email.html.haml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
%div{ 'style' => "text-align: center; color: #{OPTS.font_color};" }
%h1
Kind regards from
Kind regards from
= OPTS.image_caption
%p
We hope you also had an amazing time. Four of these unforgettable memories are attached to this email.
%p
Have fun!
%p
= image_tag attachments['animation.gif'].url
%p
= image_tag attachments['combined.jpg'].url
- if attachments.inline['combined.jpg']
%p
= image_tag attachments['combined.jpg'].url

0 comments on commit 606d5cd

Please sign in to comment.