I’ve based my code on the Agile example for uploading files, pages
362-365. I’ve successfully loaded the Picture object to the database,
but I come unstuck when trying to replicate this for a thumbnail version
of the original image:
thumbnail = Thumbnail.new
thumbnail.name = 'thumbnail_' + @picture.name.to_s
thumbnail.content_type = @picture.content_type
thumbnail.data = @picture.data
thumbnail.make_thumbnail
thumbnail.save
I get the following error on the make_thumbnail method:
ArgumentError (can’t decode image):
/app/models/thumbnail.rb:11:in read_inline' /app/models/thumbnail.rb:11:in
make_thumbnail’
Here’s the Thumbnail model:
require ‘RMagick’
include Magick
def make_thumbnail
img = Image.read_inline(self.data)
…
end
What do I have to do to thumbnail.data to get RMagick to read it?
Lindsay