Created
March 27, 2014 08:17
-
-
Save rojotek/9802776 to your computer and use it in GitHub Desktop.
upload images to carrierwave with a local server.
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
seed_data = [ | |
{model_name: "somename", image:"my_image.jpg"}, | |
#... | |
] | |
thin_server = Thread.start do | |
Thin::Server.start('0.0.0.0', 4567) do | |
run Rack::Directory.new( File.join(Dir.pwd,"seed-images") ) | |
end | |
end | |
seed_data.each do |seed| | |
model = Model.find_by_name(seed[:model_name]) | |
model.remote_image_url="http://localhost:4567/#{model[:image]}" | |
model.save | |
end | |
thin_server.kill |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment