Re: paperclip unit testing

Michal Burak
Tue, 07 Jul 2009 11:36:54 -0000

Thanks!

How do you process the image in the model?

Before the save of the model object to database I want to add another
image to it, that is a modified version of the "image" attribute.

I do:
  has_attached_file :image
  has_attached_file :image2
  after_validation :prepare_image2

And:
  def cprepare_image2
   (...)
   path = image.queued_for_write[:original].path
   self.image2 = some_rmagic_processing(path)
   (...)
  end

Is there any other way to access the uploaded image?
"image.queued_for_write[:original].path" does not look nice :/

May be use an other callback?

--
Posted via http://www.ruby-forum.com/.