Skip to content

Instantly share code, notes, and snippets.

@adeelejaz
Last active August 29, 2015 14:06
Show Gist options
  • Save adeelejaz/3d428acb425b7a0153ed to your computer and use it in GitHub Desktop.
Save adeelejaz/3d428acb425b7a0153ed to your computer and use it in GitHub Desktop.
How to download a bunch of files in Rails and save them?
require 'open-uri'
arr = ['http://example.com/file1.txt', 'http://example.com/file2.txt']
arr.each do |url|
open(url.split('/').last, 'wb') do |file|
file << open(url).read
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment