i know pdfkit focus on creating pdf from default views, but does anyone know how to render views from "show.pdf.slim" or "index.pdf.slim" instead of "show.html.slim" when requesting a pdf via the middleware? i'm looking for a global solution for the entire app. If there is an xyz.pdf.slim as view, this one should prefered instead of the default view.
to be more specific, when using the middleware, the following does not work anymore ( as by default )
respond_to do |format|
it would be nice to have that done globaly ( like prepared with the mime-type registration )
Check for the environment variable env["Rack-Middleware-PDFKit"] and render your pdf view based on it. being present or not.
Thx for the answer. But as i wrote, i'm looking for a solution for the entire app, like rendering pdf templates all the time instead of the html templates. any idea how to configure rails to use pdf templates instead of html templates?
I thought views in Rails all the way back to 2.3 could have multiple mime types. I did an article here where I talked about this. Look for view.html.pdf.haml for the section I describe this behavior. Does this no longer work in Rails 3.2?
There has been no response to a solution that appears as if it should work. If others encounter something like this, feel free to ping us here and we'll reopen this issue.