diff options
author | jpd800 <jacob.duffy@fammed.wisc.edu> | 2016-09-02 15:25:37 -0500 |
---|---|---|
committer | jpd800 <jacob.duffy@fammed.wisc.edu> | 2016-09-02 15:25:37 -0500 |
commit | cb66f19a32667a32c4984b4da8720c7ce559a444 (patch) | |
tree | 94e5aa7365348942114c49db19f988cedf6a6fa8 /railties | |
parent | 55c5dffd9f2220507ff1a7635c00a81577a8a391 (diff) | |
download | rails-cb66f19a32667a32c4984b4da8720c7ce559a444.tar.gz rails-cb66f19a32667a32c4984b4da8720c7ce559a444.tar.bz2 rails-cb66f19a32667a32c4984b4da8720c7ce559a444.zip |
Allow download of email attachments in the Mailer Preview template.
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/templates/rails/mailers/email.html.erb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/railties/lib/rails/templates/rails/mailers/email.html.erb b/railties/lib/rails/templates/rails/mailers/email.html.erb index fed96fbc85..c63781ed0c 100644 --- a/railties/lib/rails/templates/rails/mailers/email.html.erb +++ b/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 %> |