Created
July 20, 2016 13:31
-
-
Save vincentlkl/f46c85a41631465a961247afe4f90e3b to your computer and use it in GitHub Desktop.
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
# delayed job method on model | |
def process_images(urls) | |
require 'open-uri' | |
item = self | |
image_urls = urls.split(", ") | |
image_urls.each do |url| | |
file = URI.parse(url).open | |
item.images.build(:cat => cat, :avatar => file) | |
end | |
item.save | |
end | |
# Image model setup for resize | |
has_attached_file :avatar, :styles => { | |
:preview => ["150x150>",:jpg], | |
:thumb => ["150x172#",:jpg], | |
:large => ["100%", :jpg] | |
}, | |
:storage => :s3, | |
:bucket => ENV['AWS_BUCKET'], | |
:s3_credentials => { | |
:access_key_id => ENV['AWS_ACCESS_KEY_ID'], | |
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'] | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment