Daniel Sibaja
Daniel Sibaja

Reputation: 111

Protected render_to_string error

I'm trying to export with resque using PDFkit some pages. But I got several errors when I try to do it with the render_to_string.

Errors:

protected method `render_to_string' called for #<ActionController::Base:0x5a65748 @real_format=nil>

when using this:

html = ActionController::Base.new.render_to_string(
        :template => route,
        :locals => locals,
        :layout => layout
)

and this one:

undefined method `render_to_string' for Print:Module

when using this:

html = render_to_string(
        :template => route,
        :locals => locals,
        :layout => layout
)

The method I'm calling is "return_generic_pdf_kit" and lives in the /lib/print.rb, and I'm calling it from a resque worker like this:

kit = Print.return_generic_pdf_kit(url,
                             {
                                 :print_blank_eval => evaluator_type,
                                 :print_blank_prov => provider_type,
                                 :print_blank_appl => applicant_type,
                                 :form => form,
                                 :scholarship => scholarship
                             },
                             false, 1)

Hope someone can help me to find a solution.

Upvotes: 0

Views: 426

Answers (1)

Rajarshi Das
Rajarshi Das

Reputation: 12330

You can use it

ac = ActionController::Base.new()
ac.render_to_string(:template => route,
        :locals => locals,
        :layout => layout)

Upvotes: 1

Related Questions