So I was checking on how to display PDF thumbnails in Rails since for some reason creating a thumbnail version of my file in my uploader doesn't work, and it lead me to this: Convert a .doc or .pdf to an image and display a thumbnail in Ruby?
So I got up to this:
def show_thumbnail
require 'rmagick'
pdf = Magick::ImageList.new(self.pdf_file.file.path)
first_page = pdf.first
scaled_page = first_page.scale(300, 450)
end
But how do I display scaled_page
to a webpage?
I added this function in the decorator so I can do something like this:
= image_tag(pdf.pdf_file.show_thumbnail)
But it results in this error:
Can't resolve image into URL: undefined method `to_model' for #<Magick::Image:0x0000000122c4b300>