From 4142f473f00a6d085c34fb7cc9fd4480bca871e2 Mon Sep 17 00:00:00 2001 From: Malaber <32635600+Malaber@users.noreply.github.com> Date: Tue, 11 Dec 2018 15:59:04 +0100 Subject: [PATCH] Make seeds.rb beautiful --- db/seeds.rb | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 853470c..179d262 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -4,9 +4,21 @@ require 'faker' user = User.create! username: Faker::Internet.username, email: Faker::Internet.email, password: Faker::Internet.password tournament = user.tournaments.create! name: Faker::Dog.name -team1 = tournament.teams.create name: Faker::Dog.name -team2 = tournament.teams.create name: Faker::Dog.name -stage = tournament.stages.create! -match = stage.matches.create! -match.match_scores.create! team: team1, points: 0 -match.match_scores.create! team: team2, points: 1 + +@teams = [] +16.times do + team = tournament.teams.create name: Faker::HarryPotter.character + @teams << team +end +4.times do |i| + stage = tournament.stages.create! + stage.level = i + matches_amount = 2**i + matches_amount.times do |j| + match = stage.matches.create! + match.match_scores.create! team: @teams.sample, points: rand(10) + match.match_scores.create! team: @teams.sample, points: rand(10) + match.position = j + match.state = rand(7) + end +end