summaryrefslogtreecommitdiff
path: root/db/seeds.rb
blob: 3f6c6018b5ccb0dd019089d9d00f90660a75b79e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# This file should ensure the existence of records required to run the application in every environment (production,
# development, test). The code here should be idempotent so that it can be executed at any point in every environment.
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
#
# Example:
#
#   ["Action", "Comedy", "Drama", "Horror"].each do |genre_name|
#     MovieGenre.find_or_create_by!(name: genre_name)
#   end

require "csv"

[
  "Pokémon Red", "Pokémon Green", "Pokémon Blue", "Pokémon Yellow", "Pokémon Gold", "Pokémon Silver",
  "Pokémon Crystal", "Pokémon Ruby", "Pokémon Sapphire", "Pokémon Emerald",
  "Pokémon FireRed", "Pokémon LeafGreen", "Pokémon Diamond", "Pokémon Pearl",
  "Pokémon Platinum", "Pokémon HeartGold", "Pokémon SoulSilver", "Pokémon Black",
  "Pokémon White", "Pokémon Black 2", "Pokémon White 2", "Pokémon X", "Pokémon Y",
  "Pokémon Omega Ruby", "Pokémon Alpha Sapphire", "Pokémon Sun", "Pokémon Moon",
  "Pokémon Ultra Sun", "Pokémon Ultra Moon", "Pokémon Let's Go, Pikachu!",
  "Pokémon Let's Go, Eevee!", "Pokémon Sword", "Pokémon Shield",
  "Pokémon Brilliant Diamond", "Pokémon Shining Pearl", "Pokémon Legends: Arceus"
].each do |title|
  Game.create(title:)
end

csv_file = Rails.root.join("db/data/pokemon.csv")
CSV.foreach(csv_file, headers: true) do |row|
  Pokemon.create(pokedex_num: row["pokedex_num"].to_i, name: row["name"])
end