Created
August 27, 2014 10:22
-
-
Save josegranja/5778ed49e4634a2b26ed 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 'csv' | |
require 'net/http' | |
require 'json/ext' | |
csv_string = "Shen,Lui,sliu+cs@stelladot.com,,Yes,No,No | |
Shen,Lui,sliu@stelladot.com,,No,No,Yes" | |
out_file = File.open("users_data.txt", 'w') | |
CSV.parse(csv_string) do |row| | |
#get the data from csv | |
first_name = row[0] | |
last_name = row[1] | |
email = row[2] | |
password = (0...6).map { (65 + rand(26)).chr }.join | |
# password = "111111" | |
is_merch = row[5] == 'Yes' | |
is_cs = row[6] == 'Yes' | |
role = 'dsr' | |
if is_cs | |
role = 'cs' | |
elsif is_merch | |
role = 'merchant' | |
end | |
Whitelist.create!(first_name: first_name, last_name: last_name, email: email) | |
user = User.create!( | |
:first_name => first_name, | |
:last_name => last_name, | |
:password => password, | |
:email => email, | |
:email_confirmation => email, | |
:role => role, | |
phone_number: '0123456789', | |
social_security_number: '123456789', | |
birthday: 18.years.ago, | |
account_address: AccountAddress.create(address1: "117 Sherbrook Drive", address2: "Apt 3B", city: "Berkeley Heights", state: "NJ", zip_code: "07922"), | |
:state => "active") | |
out_file.puts "email: #{user.email} - DSR login:#{user.dsr_login} - Pwd:#{password}" | |
end | |
out_file.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment