Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resize image before_save with dragonfly?

In my model i have:

attr_accessible :photo
image_accessor :photo
before_save :resize_image

def resize_image
  self.photo = self.photo.process(:resize, '40x40')
end

but after save it removes my photo_uid from record in database (or doesnt write photo_uid at all)

like image 256
bravedick Avatar asked Apr 12 '12 09:04

bravedick


1 Answers

huh, i found:

image_accessor :photo do
   after_assign :resize_image
end

def resize_image
   photo.process!(:resize, '1000x650>')
end
like image 153
bravedick Avatar answered Nov 14 '22 06:11

bravedick