Tuesday, March 14, 2017

PDF Rails+Prawn 6 steps 7 images

Edit /Gem file to add prawn

> bundle
now that we have prawn installed its time to add th Prawn class i put it on app/pdf/credential.rb

here we extend the Prawn class where im receiving a subscriptor objecto to get the info from it an build a Pdf from it.

now we have the skeleton and we can work on the layout of the pdf as we want, now we need to let it being accessed from rails and the world, lets define a route

now i set the a link_to helper to access this new route so first check the new route

whith the new route i use it for the link_to helper to access the content

now that we have the link to access the pdf content we need to set it up on the controller so the controller knows what to do with it

basically first we get the object subsctiptor, then in the respondo_to we manage the format.pdf, create the new object Credential passing the object subsctriptor, and the info for the file like the name, type and that we will use a new window

No comments:

Post a Comment