I have problem with rails 4.1.6 mailer preview.
I want to see attached images in preview mode, but it doesn\'t work. I think it\'s incorrect
There is my code:
Until the Rails mail previewer is enhanced to support attachment viewing, I'm using this (hack-ish) enhancement to Mail::Part#url
to embed the attachment data into the URL itself. This lets see my inline images in the previewer (assuming I have INLINE_MAIL_PART_URLS
turned on) while preserving the original behaviour in the appropriate settings.
module InlineMailPartUrls
def url
if ENV["INLINE_MAIL_PART_URLS"] == "true"
"data:#{mime_type};base64,#{Base64.encode64(body.decoded)}"
else
super
end
end
end
class Mail::Part
prepend InlineMailPartUrls
end
I save this code to config/initializers/inline_mail_part_urls
.
https://gist.github.com/softcraft-development/2ed70a2a4d6e2c829fac