Created
December 10, 2013 00:19
-
-
Save TimPetricola/7883644 to your computer and use it in GitHub Desktop.
Carrierwave + S3 image processing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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