5

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)

korywka
  • 7,537
  • 2
  • 26
  • 48

1 Answers1

6

huh, i found:

image_accessor :photo do
   after_assign :resize_image
end

def resize_image
   photo.process!(:resize, '1000x650>')
end
korywka
  • 7,537
  • 2
  • 26
  • 48
  • What about specs? I get the following error when I run rspecs after adding the above code: `None of the functions registered with # were able to deal with the method call resize(,"200x50"). You may need to register one that can.` – Radhika Jun 11 '14 at 15:07
  • 2
    In later versions of dragonfly `image_accessor` has changed to `dragonfly_accessor` and `:resize` process to `:thumb`. – peresleguine Feb 03 '17 at 18:37