I'm trying to print a report as a pdf, which uses the render method.
This works fine. The problem comes at the end when I try to redirect
to the index page, which causes the double render. I'm sure there's a
way around this, but I'm coming up blank. If I remember right, there
was a method that acted almost like redirect_to, but wouldn't cause
the error. Please help...
Thanks
Bob
How come you want to present the report and then close it and go somewhere else? people wont see it. i dont get it , it seems you used render where you should have used send_file but i need to see your code to be sure.
When I render the report, it's to a file that can be viewed, printed,
or backed up as needed. It is to a pdf, so I'm using:
respond_to do |format|
format.pdf { send_data render_to_pdf( :action => 'idreport',
:layout =>
'pdf_report'),
:filename => "ID List
for " + @today.strftime('%m-%d-%y') + ".pdf" }
end
Then the error is caused by a redirect_to(households_url)
Bob
I'm trying to print a report as a pdf, which uses the render method.
This works fine. The problem comes at the end when I try to redirect
to the index page, which causes the double render. I'm sure there's a
way around this, but I'm coming up blank. If I remember right, there
was a method that acted almost like redirect_to, but wouldn't cause
the error. Please help...
I don't think you do - there can only be a single response to an http
request, so you can't both provide a file and show a response (unless
perhaps you were to do something like have your "success" page include
an iframe with the actual download)
Fred
Fred
That i understand , you can render the file inline or send it to the user, what i dont understand is the need to redirect after that. Please explain. But be aware that you cant double render, it will always raise an exception.
The reason for the redirect_to is to end the process after the file is
created at the index page
so the user doesn't have to find his way back. Is there a way to go to
the start or index page maybe?
Bob