【问题标题】:How to upload Email Attachments using griddler and paperclip如何使用 griddler 和回形针上传电子邮件附件
【发布时间】:2015-06-11 13:44:38
【问题描述】:

我使用Mandrill 作为入站电子邮件路由,我使用这些 gem 来接收电子邮件并将其保存在数据库中。

如何使用回形针将附件保存在单独的数据库表“Attachments”中。

【问题讨论】:

    标签: ruby-on-rails paperclip mandrill griddler


    【解决方案1】:

    Griddler::Email 有一个attachments 属性,即:

    包含任何附件的 File 对象数组。

    所以,如果你有这样的模型:

    class Assessment
      has_attached_file :file
    end
    

    您只需这样做,例如:

    @email.attachments.each{|f| Attachment.create(file: f)}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-06
      • 1970-01-01
      • 1970-01-01
      • 2014-11-09
      相关资源
      最近更新 更多