我有一个 ActionMailer 设置,可以从 S3 发送带有附件的电子邮件。我这样做是这样的:
def job_apply(current_tenant, applicant)
@current_tenant = current_tenant
@applicant = applicant
file = open(applicant.resume.url).read
attachments[applicant.resume] = file
email_with_name = "#{@current_tenant.name} <#{@current_tenant.help_email}>"
mail(from: email_with_name, to: applicant.job.apply_email, subject: "New Job Application")
end
application.resume.url 返回一个正确的 URL,我可以在浏览器中打开它并检索文件,但是我收到以下错误:
Message undefined method `ascii_only?' for #<ApplicantResumeUploader:0x007fe6bc5c28a8>
File /Users/cmalpeli/.rvm/gems/ruby-1.9.3-p194@job_board/gems/mail-2.4.4/lib/mail/encodings.rb
Line 103
这是 encodings.rb 中的代码:
98 def Encodings.decode_encode(str, output_type)
99 case
100 when output_type == :decode
101 Encodings.value_decode(str)
102 else
103 if str.ascii_only?
104 str
105 else
106 Encodings.b_value_encode(str, find_encoding(str))
107 end
108 end
我有点不知所措从这里去哪里......
任何帮助,将不胜感激...