我有一个回形针文件,要添加为我的电子邮件的附件...。
类UserMailer
@record =记录 attachments ??? How to add a paperclip file?
mail( :to => "#{record.email}",
:subject => "XXXXXXXX"
)
end
通过Google似乎没有关于该主题的任何内容,如果您有任何想法,我很乐意听到:)
谢谢
更新 @comment.attachments.each do |a|
tempfile = File.new("#{Rails.root.to_s}/tmp/#{a.attachment_file_name}", "w")
tempfile << open(a.authenticated_url())
tempfile.puts
attachments[a.attachment_file_name] = File.read("#{Rails.root.to_s}/tmp/#{a.attachment_file_name}")
# Delete it tempfile
#File.delete("#{Rails.root.to_s}/tmp/#{a.filename}")
end
最佳答案
从Ruby on Rails指南(仅可通过Bing访问):
http://guides.rubyonrails.org/action_mailer_basics.html#sending-emails-with-attachments
剩下的就是将附件(如果在S3中)下载到file对象或对其进行访问,将其存储在本地。尝试使用open-uri。
关于ruby-on-rails - 回形针+ ActionMailer-添加附件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4356936/