ruby-on-railsdelayed-jobprawnprawnto

Delayed Job with Prawn and Prawnto


I currently generate a report for a single user using prawn and prawnto. When the user clicks on download report, the controller action gets called which then uses PRAWNTO to call the report.pdf.prawn which is in my view. This is all good MVC structure.

I now want to use delayed_job gem to create a combined report for 200 users. I have decided to use delayed_job (as it plays nice with heroku). I'm currently starting the delayed job when a controller action is called (eg. def generate_batch_report). I have created a Job object called BatchReportJob who's perform method is called by the controller action. This is where I'm stuck - I don't know what to do in the perform method. I basically want reports to be printed for every user in one pdf and I want to keep my prawn file code in the View folder.

Any suggestions would be appreciated.


Solution

  • I realized prawnto is a an old gem which is not being maintained - would not recommend anyone else to use it unless you're sure it fits your criteria. I followed the Revised Railscast at http://railscasts.com/episodes/153-pdfs-with-prawn-revised which worked for me.