Migrate image to new model.

55 views
Skip to first unread message

Brian Bokor

unread,
Apr 20, 2012, 5:12:40 PM4/20/12
to carri...@googlegroups.com
I have been able to migrate my images to the new model but it keeps the old image around.  I think I'm doing this incorrect.

I have a Photo Model and ImageUploader with Fog (have also tried the remote_image_url method

I wanted to migrate my old images to the Photo Model and would rather just set the image field with the filename then reprocess later, but it won't let me do this since it is serialized to the Uploader.  Any suggestions


Would be ideal but doesn't work
photo = Photo.new(:attachable =>old_model)
photo.image = "test.jpg"
photo.save!

Works but doesn't delete old files
photo = Photo.new(:attachable => old_model)
photo.remote_image_url = "http://test.com/test.jpg"
photo.image.recreate_versions! 
photo.save!



Brian Bokor

unread,
Apr 26, 2012, 11:09:37 AM4/26/12
to carri...@googlegroups.com
This works!      

      photo = Photo.create(:attachable => old_model, :order => 1)
      photo.write_uploader(:image, old_model.photo)
      photo.save!
Reply all
Reply to author
Forward
0 new messages