Here I want to take a screenshot of an external url, and I use IMGkit with CarrierWave.
#Class Micropost
after_create :take_snapshot
def take_snapshot
file = Tempfile.new(["template_#{self.id.to_s}", 'jpg'], 'tmp', :encoding => 'ascii-8bit')
file.write(IMGKit.new(self.external_url).to_jpg)
file.flush
self.snapshot = file
self.save
file.unlink
end
and the screenshot get generated is.....
So whats wrong with it?