Skip to content

Commit

Permalink
Revert seed file changes
Browse files Browse the repository at this point in the history
  • Loading branch information
JudahSan committed Oct 18, 2024
1 parent fcee9ff commit f2e058d
Showing 1 changed file with 1 addition and 58 deletions.
59 changes: 1 addition & 58 deletions db/seeds.rb
Original file line number Diff line number Diff line change
@@ -1,65 +1,8 @@
# frozen_string_literal: true

require 'faker'

# 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 bin/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)

## User Seeds for local dev testing and setup.

LOCATIONS = ['Nairobi', 'Mombasa', # Kenya
'Kampala', 'Entebbe', # Uganda
'Dar es Salaam', 'Arusha', # Tanzania
'Bujumbura', 'Gitega', # Burundi
'Kigali', 'Butare'].freeze # Rwanda

def build_user
user = User.new

user.email = Faker::Internet.email
pass = Faker::Internet.password
user.password = pass
user.password_confirmation = pass
user.github_username = Faker::Internet.username
user.name = Faker::Name.name
user.phone_number = Faker::Number.number(digits: 10)

user.save if user.valid?
end

def build_country
country = Country.new

country.name = %w[Kenya Uganda Tanzania Rwanda Burundi].sample

country.save if country.valid?
end

def build_chapter
chapter = Chapter.new

chapter.name = [Faker::Name.middle_name.to_s, 'Chapter'].join(' ')
chapter.country = Country.all.sample
chapter.location = LOCATIONS.sample
chapter.description = "The East African chapter in #{chapter.location}"

chapter.save if chapter.valid?
end

10.times do
build_user
end

5.times do
build_country
end

10.times do
build_chapter
end
# Character.create(name: "Luke", movie: movies.first)

0 comments on commit f2e058d

Please sign in to comment.