forked from Ada-C9/grocery-store
-
Notifications
You must be signed in to change notification settings - Fork 0
/
seeds.rb
48 lines (43 loc) · 1.15 KB
/
seeds.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
require 'csv'
require 'faker'
# Students do not need to modify this file
# This is the file created by instructors to create all CSV files
# orders
# id = 1
# CSV.open("support/orders.csv", "w") do |csv|
# 100.times do
# foods = ""
# rand(1..4).times do
# foods += Faker::Food.ingredient + ":" + Faker::Commerce.price.to_s + ";"
# end
#
# foods = foods.chomp(';')
# csv << [id, foods]
# id += 1
# end
# end
# customers
# id = 1
# CSV.open("support/customers.csv", "w") do |csv|
# 35.times do
# csv << [id, Faker::Internet.email,
# Faker::Address.street_address, Faker::Address.city, Faker::Address.state_abbr, Faker::Address.zip_code]
# id += 1
# end
# end
# online orders
# id = 1
# statuses = %i(pending paid processing shipped complete)
# CSV.open("support/online_orders.csv", "w") do |csv|
# 100.times do
# foods = ""
# rand(1..4).times do
# foods += Faker::Food.ingredient + ":" + Faker::Commerce.price.to_s + ";"
# end
#
# foods = foods.chomp(';')
# # id, string of foods, customer ID, random status
# csv << [id, foods, rand(1..35), statuses.sample]
# id += 1
# end
# end