Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6095961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:52:17+00:00 2026-05-23T12:52:17+00:00

I am trying to create a PDF document in the background via Resque background

  • 0

I am trying to create a PDF document in the background via Resque background job.

My code for creating the PDF is in a Rails helper method that I want to use in the Resque worker like:

class DocumentCreator
  @queue = :document_creator_queue
  require "prawn"

  def self.perform(id)
    @doc = Document.find(id)

    Prawn::Document.generate('test.pdf') do |pdf|
      include ActionView::Helpers::DocumentHelper
      create_pdf(pdf)
    end
  end
end

The create_pdf method is from the DocumentHelper but I am getting this error:

undefined method `create_pdf' 

Anyone know how to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:52:18+00:00Added an answer on May 23, 2026 at 12:52 pm

    You’re trying to call an instance method (create_pdf) from a class method (self.perform). Your code would only work if your DocumentHelper defined create_pdf as a class method:

    def self.create_pdf
    

    If you don’t need access to create_pdf in your views, you may consider moving it to your Document class instead, as an instance method, and then you can do @doc.create_pdf(pdf).

    However, if you need access to create_pdf in your views as well, you can either put a module_function :create_pdf inside your DocumentHelper file, or you can dynamically add this in your worker:

    DocumentHelper.module_eval do
      module_function(:create_pdf)
    end
    DocumentHelper.create_pdf(pdf)
    

    Then you can properly call DocumentHelper.create_pdf.

    Also, in Rails 3, I think you only need include DocumentHelper, rather than include ActionView::Helpers::DocumentHelper.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a method that will send a PDF file directly to
I'm trying to create a function that would return a PDF document. Something like
I am trying to create an app that converts html to a pdf doc
I'm trying to dynamically create a PDF using the TCPDF library in a document
I am trying to create a pdf document in c# using iTextSharp 5.0.6. I
I'm trying to create a PDF based on the information that resides on a
I am trying to create a unit test that generates an empty test document
I am trying to create a new document UTI for my App so that
I am trying to create a regex to parse document links (pdf, ppt, xls,
I am trying to programmatically create a number of PDF documents with a watermark

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.