copying an image from one mount (+model) to another

Showing 1-2 of 2 messages
copying an image from one mount (+model) to another Joey 12/7/11 3:10 PM
Hi all,

I have a need to occasionally populate the image(s) stored on one
model's uploader from another. E.g.,

class Artwork
  mount_uploader :image, ArtworkUploader
end

class Artist
  mount_uploader :image, ArtistUploader

  # copy an artwork image into the artist and perform necessary
processing
  def replace_image_from(artwork)
    artwork.image.cache_stored_file! unless artwork.image.cached?
    self.image_cache = artwork.image_cache
    self.store_image!
  end
end

This almost worked, but our uploaders increment a version number that
goes into the store_path, and it turns out that calling
artwork.image.cache_stored_file! increments the version number on the
artwork, which actually hasn't changed. Is there a simpler way to read
the original file from one mount point into another?

Thanks,
Joey

Re: copying an image from one mount (+model) to another Joey 12/10/11 6:03 PM
For those interested, this somewhat simpler approach has the desired
effect:

class Artist
  mount_uploader :image, ArtistUploader
  def replace_image_from(artwork)    self.image = artwork.image.file 
  self.save!  endend