I am afraid i am getting something completely wrong with the new active storage feature. What I want to do is to create an pdf ( I am using WickedPdf ) and attach it to a model. Here is the first issue, The only chance i figured out so far is to write to a file first and then open this file to create the attachment.
self.document.attach( {
filename: "filename.pdf",
io: File.open(pdf_document)
})
Is there a way to create the attachment from a string?
Afterwards I try attach this file to a mail. This fails because it needs a file again, not a blob.
attachments[document.filename.to_s] = document.blob
Creating a file again seems really weird to me.
Can please someone enlighten me whats the proper way to achieve that without writing files at all? I seems unnecessary, inefficent and time consuming to me.
=====
Solution Part 2: So I managed to attach the document without creating a file
attachments[document.filename.to_s] = {:mime_type => 'application/pdf',
:content => document.attachment.blob.download }
Part one is still missing. Hope someone has an answer!
document.blob
with'this is a test'
and confirm that the attachment is there. The issue is likely in the first part with active storage. – Nash