I have an app. where I am generating PDF files. I use a .rxml template
to generate content that I then write to a file using
render_to_string().
That works fine, however, if I make a call to render(:text => ‘blah’)
afterwards, I see an error that makes it look like the render is
identifying the response as XML, even though render_to_string is not
supposed to affect the action response to the browser.
Here’s my code:
File.open(pdfgen.xfdf_file, "w") do |f|
f.write(render_to_string(:layout => false))
end
begin
pdfgen.generate_pdf
rescue
return render(:text => 'There was an error generating your quote',
:layout => false)
end
If the rescue clause runs, I get this:
"XML Parsing Error: syntax error
Location: http://localhost:3001/artisan_qualifiers/2805/print_quote
Line Number 1, Column 1:
There was an error generating your quote"
However, if I comment the call to render_to_string out, the text will
generate normally. Almost as if the call to render_to_string somehow
caused some internal flag to be set that the response would be XML, even
though it won’t.
So, two questions:
-
Does render_to_string() modify the response even though the API docs.
say that it doesn’t? -
Is there an alternative/better way to render the output of my RXML
file to another file?
Thanks,
Wes