Reputation: 32192
I need the HTML generated with absolute asset paths so that I can then feed the HTML to a PDF generation engine. So the route would be something like
/report.pdf
which would generate the view for
/report.html
and then post process that with the PDF generation engine.
http://apidock.com/rails/AbstractController/Rendering/render_to_string
will get me half way there but will leave the assets with their relative paths.
Upvotes: 0
Views: 804
Reputation: 6942
I have same issue while generating pdf. I have set asset_host in environments
config.action_controller.asset_host = "http://localhost:3000"
Or before render_to_string Add this line
host = ActionController::Base.asset_host
ActionController::Base.asset_host = request.protocol + request.host_with_port if host.blank?
I am using in my gem acts_as_flying_saucer
I hope this is helpful But i have tested on 2.x and rails 3.0.x. I haven't tested with rails 3.1 i will test and let you know as early as possible
Upvotes: 1