Add database seeds
This commit is contained in:
parent
3053b0681e
commit
2507c782e5
17
db/seeds.rb
17
db/seeds.rb
|
|
@ -1,9 +1,12 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# This file should contain all the record creation needed to seed the database with its default values.
|
||||
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
|
||||
#
|
||||
# Examples:
|
||||
#
|
||||
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
|
||||
# Character.create(name: 'Luke', movie: movies.first)
|
||||
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.scores.create! team: team1, score: 0
|
||||
match.scores.create! team: team2, score: 1
|
||||
|
|
|
|||
Loading…
Reference in New Issue