相关疑难解决方法(0)

paperclip + ActionMailer - 添加附件?

我有一个回形针文件,我想添加为我的电子邮件的附件....

class UserMailer <ActionMailer :: Base def XXXXXX_notification(record)@record = record

  attachments ??? How to add a paperclip file?

  mail( :to => "#{record.email}", 
        :subject => "XXXXXXXX"
        )
end
Run Code Online (Sandbox Code Playgroud)

通过谷歌似乎没有任何关于这个话题,如果你有什么想法,我很想听听:)

谢谢

UPDATE

  @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
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails actionmailer paperclip ruby-on-rails-3

10
推荐指数
2
解决办法
4994
查看次数