Skip to content

Instantly share code, notes, and snippets.

@aokolish
Created July 1, 2014 17:43
Show Gist options
  • Save aokolish/4f8d27ac8ef3eb23503d to your computer and use it in GitHub Desktop.
Save aokolish/4f8d27ac8ef3eb23503d to your computer and use it in GitHub Desktop.
class GeneratedPDF
def generate
# pdf stuff...
pdf_file = Tempfile.new(['something', '.pdf'])
pdf_file.binmode
pdf_file.write(pdf_string)
pdf_file
end
end
class GeneratedPdfJob < Struct.new(:generated_pdf)
def perform
generated_pdf.update_attributes!(pdf: File.new(generated_pdf.generate))
end
end
@aokolish
Copy link
Author

aokolish commented Jul 1, 2014

Sometimes, line 3 of generated_pdf_job.rb raises Errno::ENOENT. Is that because the Tempfile has been GC'd and unlinked?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment