Last active
June 30, 2016 13:46
-
-
Save serg2801/0634d1c94dcb1a8a85072d5de9d69bde 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
require 'open-uri' | |
def all_product | |
products = Product.all | |
products.each do |product| | |
id = product.id | |
image_path = product.image.path.split('/') | |
image_name = image_path[4] | |
save_img(image_name, id) | |
end | |
end | |
def save_img(image_name, id_product) | |
open('thumb_' + "#{image_name}", 'wb') do |file| | |
file << open('https://geschenkeheld-community.s3.amazonaws.com/uploads/product/image/' + "#{id_product}" + '/' + "#{image_name}").read | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment