Hi,
I've created a layout which can take several seconds until it's renderd.
So I moved the generation into a sidekiq worker to run in a background job.
The issue is now that render_to_string returns a NoMethodError.
I've tried several includes but nothing works.
Did anybody solved the problem?
WARN: NoMethodError: undefined method `render_to_string' for #
class PdfWorker
include Sidekiq::Worker
sidekiq_options queue: 'files', retry: false, backtrace: true
def perform(business_id, user_id, places)
file = WickedPdf.new.pdf_from_string(
render_to_string template: '/path_to_tmeplate/template.pdf', disposition: 'attachment', layout: 'application.print', lowquality: false, image_quality: 100,
margin: {top: 10, bottom: 0, left: 20, right: 20}
)
FilemailerMailer.file(file).deliver_now!
end
end
Solved
ApplicationController.new.render_to_string
Most helpful comment
Solved