Make seeds.rb beautiful
This commit is contained in:
parent
3e4853046a
commit
4142f473f0
20
db/seeds.rb
20
db/seeds.rb
|
|
@ -4,9 +4,21 @@ require 'faker'
|
||||||
|
|
||||||
user = User.create! username: Faker::Internet.username, email: Faker::Internet.email, password: Faker::Internet.password
|
user = User.create! username: Faker::Internet.username, email: Faker::Internet.email, password: Faker::Internet.password
|
||||||
tournament = user.tournaments.create! name: Faker::Dog.name
|
tournament = user.tournaments.create! name: Faker::Dog.name
|
||||||
team1 = tournament.teams.create name: Faker::Dog.name
|
|
||||||
team2 = tournament.teams.create name: Faker::Dog.name
|
@teams = []
|
||||||
|
16.times do
|
||||||
|
team = tournament.teams.create name: Faker::HarryPotter.character
|
||||||
|
@teams << team
|
||||||
|
end
|
||||||
|
4.times do |i|
|
||||||
stage = tournament.stages.create!
|
stage = tournament.stages.create!
|
||||||
|
stage.level = i
|
||||||
|
matches_amount = 2**i
|
||||||
|
matches_amount.times do |j|
|
||||||
match = stage.matches.create!
|
match = stage.matches.create!
|
||||||
match.match_scores.create! team: team1, points: 0
|
match.match_scores.create! team: @teams.sample, points: rand(10)
|
||||||
match.match_scores.create! team: team2, points: 1
|
match.match_scores.create! team: @teams.sample, points: rand(10)
|
||||||
|
match.position = j
|
||||||
|
match.state = rand(7)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue