RTeX::Document::GenerationError with Phusion Passenger

In a recent project I experienced a RTeX::Document::GenerationError only when using Phusion Passenger. After a closer look I’ve seen that the PDF has been successfully created but the redirect to the following request failed. Everything works fine with mongrel.

However, the error messaged looked like the following:

RTeX::Document::GenerationError in BillsController#index</h3> <pre>Could not find result PDF document.pdf after generation.

[...]

In this case the Rails app renders a bill and sends it via email to the customer and then redirects back to the bill listing. The error does not occur during the bill generation. The email including the pdf will be send successfully.

The error happens in the redirection to bills_path. The latex log document.log show that Rails or RTex has rendered html as it should but then passed it to RTex to render a pdf from html (instead of tex).

Workaround

In order to prevent this behaviour I studied the gem and found the following workaround. After generating the PDF simply put

Thread.current[:_rendering_rtex] = false

before the redirect. The RTeX::Document::GenerationError should be gone.

Eine Reaktion zu “RTeX::Document::GenerationError with Phusion Passenger”

  1. RTeX::Document::GenerationError with Phusion Passenger ERP1

    [...] Read the rest here: RTeX::Document::GenerationError with Phusion Passenger [...]