How to upload Email Attachments using griddler and paperclip

559 Views Asked by At

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.

1

There are 1 best solutions below

0
On

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)}