Skip to content

Instantly share code, notes, and snippets.

@sahidursuman
Forked from avogel3/prawn2s3.rb
Created May 29, 2019 18:24
Show Gist options
  • Select an option

  • Save sahidursuman/aa2d30136dea1917886e1ec5909bc2f6 to your computer and use it in GitHub Desktop.

Select an option

Save sahidursuman/aa2d30136dea1917886e1ec5909bc2f6 to your computer and use it in GitHub Desktop.

Revisions

  1. @avogel3 avogel3 revised this gist Jul 21, 2016. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions prawn2s3.rb
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,9 @@
    # 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
    # Let 'Document' be our paperclip model, belongs_to :user
    pdf = OurCustomPdf.new(@user, "pdf")
    upload = Document.new(user_id: @user.id)
    upload = @user.documents.new
    upload.attachment = StringIO.new(pdf.render)
    upload.save!

  2. @avogel3 avogel3 created this gist Jul 20, 2016.
    10 changes: 10 additions & 0 deletions prawn2s3.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    # 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 = Document.new(user_id: @user.id)
    upload.attachment = StringIO.new(pdf.render)
    upload.save!