mileszs/wicked_pdf — Issue #78: WickedPDF and Rails 3 Template Inheritance
Author: taelor
Created: 2012-01-22 00:16:22+00:00
State: open

(stop me if there is a way to do this, and I'm just too noob to figure it out. Just now been fooling around with Rails 3, its been hell getting our app to the point where we can use Rails 3)

With Rails 2, we were doing a self implemented really hackish way of doing template inheritance, that worked from the views down.

Now that we are working on getting the app on Rails 3, we removed that old hackish way of doing the template inheritance. The only problem is now that doesn't work with Wicked PDF now.

It would be nice to be able to say :template => "show" for our PDFs, and if the show isn't there in the current controller's view folder, then it will go back to the parent controllers view folder and look for the show template file.

I've looked at the internals for WickedPDF, and I think the spot that would need to be changed is the render_pdf_to_string() method. I am not sure if there are options to allow that to abide by the template inheritance rules that normal render does in Rails 3.

I am really unsure how Rails 3 even calls render_to_string now that all the internals have changed dramatically from Rails 2. So I figure we have two options here.

1) Figure out how Rails 3 determines the template inheritance and use some built in methods to figure out what file to call (what prefixes to add in the :template => "whatever_file" option). I figure this would be preferred if doable some how, but may not be backwards compatible.

Here is the commit that added template inheritance to Rails3. https://github.com/rails/rails/commit/0f32febad7bca595df44

2) Write code that could mimic this functionality and add it to wicked pdf. this could possibly work with rails 3.0, and maybe even Rails 2.3. It actually might even be a little easier.

Here is a blog post detailing a possible solution. http://jkfill.com/2011/03/11/implementing-a-rails-3-view-resolver/

I'd love to help out and contribute this functionality to Wicked PDF since it has been just an absolutely wonderful solution for 90% of our PDF needs.

Thanks!
taelor