Monday, March 27, 2017

RAILS Save Form Fields Upcasing them

We can uppercase the forms with several ways but at the time to save the data by default, the form will send the info lower case so upcase the view does not solve the problem we need to work on the controller, or model here it the simple way to do it on model.

First we add the css transformation to upcase the field via class:



Now that we have to put the class in the Field's Form



now that we have the form uppercase the text input its time to work on the model

and that is all, for a better comprension of the upcase! or better understanding on the model part check out statck overflow and ruby guides

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