diff --git a/db/seeds.rb b/db/seeds.rb index 7a9fa04..007d0e5 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -28,32 +28,31 @@ Expense.create!(name: 'Transportation', amount: 3000, pricing_type: 'fixed') Expense.create!(name: 'Invitations', amount: 200, pricing_type: 'fixed') Expense.create!(name: 'Cake', amount: 500, pricing_type: 'fixed') -300.times do - Guest.create!(first_name: Faker::Name.first_name, - last_name: Faker::Name.last_name, - email: Faker::Internet.email, - phone: Faker::PhoneNumber.cell_phone) -end -{ +samples = { close_family: 10, family_1_group_a: 5, family_1_group_b: 5, family_2_group_a: 7, family_2_group_b: 15, previous_company: 5, - new_company: 15, + new_company: 20, college: 10, high_school: 5, childhood: 5, basket_team: 20, soccer_team: 15, dance_club: 10 -}.each do |affinity_group, count| - Guest.all.sample(count).each do |guest| - guest.affinity_group_list.add(affinity_group) - guest.save! - rescue => e - binding.pry - end +}.each_with_object([]) do |(affinity_group, count), acc| + count.times { acc << affinity_group } +end + +300.times do + guest = Guest.create!(first_name: Faker::Name.first_name, + last_name: Faker::Name.last_name, + email: Faker::Internet.email, + phone: Faker::PhoneNumber.cell_phone) + + guest.affinity_group_list.add(samples.sample) + guest.save! end