TIL – Using a Cloudinary Resource with the Wicked PDF Gem

Today I was working on an pdf.erb view template in rails. In this case, I wanted to add into the PDF some images that we stored in cloudinary. My first instinct was to use the image tag that’s part of the cloudinary gem:
[ruby]
          <%= cl_image_tag(graphic.stored_at, secure: true,
                           transformation:
                               {width: 250,
                                height: 250,
                                crop: 'fill'}
              )
          %>
However, the image would not display. Since I’ve rendered images in other PDFs, I remembered, that I needed to use the wicked_pdf_image_tag instead. To get the correct resource name from cloudinary, a quick spin through their help documentation yielded cl_image_path:
[ruby]
<%= wicked_pdf_image_tag(cl_image_path(graphic.stored_at, 
                                             secure: true,
                                             width: 250,
                                             height: 250, 
                                             crop: :fill)
)
%>
Notice the slightly different syntax for the transformation information between the two? However, this also didn’t work, but a spin through some Stack Overflow articles showed me that my problem may be with trying to force https. Dropping the secure: true parameter worked!
[ruby]
<%= wicked_pdf_image_tag(cl_image_path(graphic.stored_at
                                             width: 250,
                                             height: 250, 
                                             crop: :fill)
)
%>