Permalink
Browse files

Merge pull request #26371 from duffyjp/master

Allow download of email attachments in the Mailer Preview template.
  • Loading branch information...
guilleiguaran committed Sep 3, 2016
2 parents 841bd89 + cb66f19 commit 77ab69a249fce0e7a5bb9c7569962d18460e5e97
Showing with 4 additions and 1 deletion.
  1. +4 −1 railties/lib/rails/templates/rails/mailers/email.html.erb
@@ -88,7 +88,10 @@
<% unless @email.attachments.nil? || @email.attachments.empty? %>
<dt>Attachments:</dt>
<dd>
<%= @email.attachments.map { |a| a.respond_to?(:original_filename) ? a.original_filename : a.filename }.join(', ') %>
<% @email.attachments.each do |a| %>
<% filename = a.respond_to?(:original_filename) ? a.original_filename : a.filename %>
<%= link_to filename, "data:application/octet-stream;charset=utf-8;base64,#{Base64.encode64(a.body.to_s)}", download: filename %>
<% end %>
</dd>
<% end %>

0 comments on commit 77ab69a

Please sign in to comment.