Hi Sebastian, please ignore my last post about how to change
file_column.rb, I''m using a different strategy this time:
now I have my photo model set this way:
require ''RMagick''
class Photo < ActiveRecord::Base
file_column :image, :thumb
before_validation :resize_image
private
def resize_image
@magick_image = Magick::Image::read(image).first
l = @magick_image.change_geometry(''250>x250>'')
do |w, h, img|
img.resize(w, h)
end
l.write(image)
self.thumb =
@magick_image.change_geometry(''100>x100>'') do |
w, h, img|
img.resize(w, h)
end
end
end
the resize for the main image works fine, but when trying to do the
same for the thumb field, I get
undefined method `size'' for #<Magick::Image:0x7c1feec>
/lib/file_column.rb:139:in `thumb=''
/lib/file_column.rb:129:in `thumb=''
/app/models/photo.rb:19:in `resize_image''
/app/controllers/photo_controller.rb:29:in `upload''
script/server:49
i''m a little confused as for why I have to use l.write(image) instead
of just doing self.image = @magick_image , and I figure that for the
same reason self.thumb = @magick_image also doesn''t work... but when
I try l.write(thumb), i get nothing, not even errors :P
hope I''m making sense here...
thanks
Oliver