Created
July 1, 2014 17:43
-
-
Save aokolish/4f8d27ac8ef3eb23503d to your computer and use it in GitHub Desktop.
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
class GeneratedPDF | |
def generate | |
# pdf stuff... | |
pdf_file = Tempfile.new(['something', '.pdf']) | |
pdf_file.binmode | |
pdf_file.write(pdf_string) | |
pdf_file | |
end | |
end |
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
class GeneratedPdfJob < Struct.new(:generated_pdf) | |
def perform | |
generated_pdf.update_attributes!(pdf: File.new(generated_pdf.generate)) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sometimes, line 3 of generated_pdf_job.rb raises
Errno::ENOENT
. Is that because the Tempfile has been GC'd and unlinked?