I need to be able to attach a file to mail (using Mailer) for a recently downloaded file that is not associated with any model.
In the code that appears for the upload form:
<%= form_for(:mail, :url => {:action => 'send_mail'}, :html => {:multipart => true}) do |f| %>
<table summary="send_table">
<tr>
<th>Attachment</th>
<td><%= f.file_field(:attachment) %><a id="attachment"></a></td>
</tr>
</table>
<%= submit_tag "Send!" %>
Now, what I'm looking at in the send_mail action is something like:
MyMailer.send_mail(params[:mail][:attachment]).deliver
with parameters [: mail] [: attachment] - the path to the temp file loaded using the form. How can I do that?
This also implies another question: should I manually delete the file from temp after sending mail? If so, how?
source
share