-
-
Save sahidursuman/aa2d30136dea1917886e1ec5909bc2f6 to your computer and use it in GitHub Desktop.
Uploading Prawn Generated PDFs to S3 in Rails using Paperclip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ran into an issue recently where I wanted to use our custom prawn class to generate a PDF, then upload it to Amazon S3 using paperclip. | |
# Let 'OurCustomPdf' be our prawn class. | |
# Let the variable '@user' be our our model, has_many :documents | |
# Let 'Document' be our paperclip model, belongs_to :user | |
pdf = OurCustomPdf.new(@user, "pdf") | |
upload = @user.documents.new | |
upload.attachment = StringIO.new(pdf.render) | |
upload.save! | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment