Add database seeds

This commit is contained in:
Thor77 2018-11-25 20:13:16 +01:00
parent 3053b0681e
commit 2507c782e5
No known key found for this signature in database
GPG Key ID: 5051E71B46AA669A
1 changed files with 10 additions and 7 deletions

View File

@ -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