Have file in @attachment
. From debug:
"datafile"=>#<ActionDispatch::Http::UploadedFile:0x3eee9c0 @original_filename="filename.jpg",
@content_type="image/jpeg",
@headers="Content-Disposition: form-data; name=\"datafile\"; filename=\"filename.jpg\"\r\nContent-Type: image/jpeg\r\n",
@tempfile=#<File:C:/Users/.../RackMultipart20121026-2452-g369hf>>,
It was uploaded via a user form.
I'm trying to attach it to an email:
...
attachments[@attachment.original_filename] = @attachment
mail(:to => "[email protected]", :subject => "test", :from => @fromaddress)
Which errors:
undefined method `length' for #
I have also tried
attachments[@attachment.original_filename] = @attachment.tempfile
Which errors:
undefined method `[]' for #<Tempfile:0x5629e48>
@attachment.original_filename
returns the proper filename ("filename.jpg" in example)
Anything obvious?