有文件在@attachment
. 从调试:
"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>>,
它是通过用户表单上传的。
我正在尝试将其附加到电子邮件中:
...
attachments[@attachment.original_filename] = @attachment
mail(:to => "email@email.com", :subject => "test", :from => @fromaddress)
哪些错误:
# 未定义的方法“长度”
我也试过
attachments[@attachment.original_filename] = @attachment.tempfile
哪些错误:
undefined method `[]' for #<Tempfile:0x5629e48>
@attachment.original_filename
返回正确的文件名(例如“filename.jpg”)
有什么明显的吗?