Skip to content

Instantly share code, notes, and snippets.

@TimPetricola
Created December 10, 2013 00:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TimPetricola/7883644 to your computer and use it in GitHub Desktop.
Save TimPetricola/7883644 to your computer and use it in GitHub Desktop.
Carrierwave + S3 image processing
# Image model with ImageUploader mounted on image attribute
class Image < ActiveRecord::Base
mount_uploader :image, ImageUploader
def process_image!(versions = [])
return unless self.image.file.exists?
hosted_image.should_process = true
hosted_image.cache_stored_file!
hosted_image.retrieve_from_cache!(hosted_image.cache_name)
hosted_image.recreate_versions!(*versions)
self.processed = true
save(validate: false)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment