1

I'm using Mandrill as Inbound email routing and I'm using those gems to receive emails and save it in a database.

How can I save the attachments in separated database table "Attachments" using paperclip.

maelswarm
  • 1,163
  • 4
  • 18
  • 37
dyaa
  • 1,440
  • 18
  • 43

1 Answers1

1

Griddler::Email has an attachments attribute, which is:

An array of File objects containing any attachments.

So, if you have a model like this:

class Assessment
  has_attached_file :file
end

You would simply do, for example:

@email.attachments.each{|f| Attachment.create(file: f)}
lunr
  • 5,159
  • 4
  • 31
  • 47