Day 2

Janice Wong
Jul 26, 2017 · 2 min read

Got the PDFKit gem to work! I’m working on Wylie’s app to be able to search and select multiple drugs, output a table of the results and their side effects, and export the table to a PDF.

I got a (keyword “a”) table to export to PDF, but I’ll need to ensure it contains only the drugs that were selected in the index page. I believe I’ll need to create a Search model, with a joint table containing the drugs for each search (each entry will have a drug_id / drug_name and a search_id). I also want to incorporate an Excel import feature, so admins can update the drug and side effect database as they please — I think I’ll have to play around with some combination of the Roo and Paperclip gems.

Now to reflect on the challenges I faced today —
I originally wanted to use the WickedPDF gem, but had difficulty getting it to work (following documentation / lack of documentation). I then tried Prawn, which has a pretty great RailsCasts video to walk you through. Then I realized you can’t render HTML views to PDFs using Prawn. You can render texts / tables … though I couldn’t really get this to work in the latest version of Rails. Ultimately, I was able to PDFKit to work using this very helpful tutorial!

So that was pretty freaking exciting, getting it to work on my local server. HOWEVER, getting this on Heroku was quite a pain in my arse, as has been the case with many of my apps. To figure this out, I used a combination of the following links (in sequence):

And that was it! Tada. Success. Bliss. etc etc.

Goodnight.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade