Add seeds and weapons.csv
This commit is contained in:
parent
ddce195afa
commit
932c82d219
2 changed files with 1149 additions and 7 deletions
36
db/seeds.rb
36
db/seeds.rb
|
|
@ -1,7 +1,29 @@
|
|||
# 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 'csv'
|
||||
|
||||
csv_text = File.read(Rails.root.join('lib', 'seeds', 'weapons.csv'))
|
||||
csv = CSV.parse(csv_text, headers: true, encoding: 'UTF-8')
|
||||
csv.each do |row|
|
||||
w = Weapon.new
|
||||
w.name_en = row['name_en']
|
||||
w.name_jp = row['name_jp']
|
||||
w.granblue_id = row['granblue_id']
|
||||
w.rarity = row['rarity']
|
||||
w.element = row['element']
|
||||
w.proficiency = row['proficiency']
|
||||
w.series = row['series']
|
||||
w.flb = row['flb']
|
||||
w.ulb = row['ulb']
|
||||
w.max_level = row['max_level']
|
||||
w.max_skill_level = row['max_skill_level']
|
||||
w.min_hp = row['min_hp']
|
||||
w.max_hp = row['max_hp']
|
||||
w.max_hp_flb = row['max_hp_flb']
|
||||
w.max_hp_ulb = row['max_hp_ulb']
|
||||
w.min_atk = row['min_hp']
|
||||
w.max_atk = row['max_hp']
|
||||
w.max_atk_flb = row['max_hp_flb']
|
||||
w.max_atk_ulb = row['max_hp_ulb']
|
||||
w.save
|
||||
end
|
||||
|
||||
puts "There are now #{Weapon.count} rows in the weapons table."
|
||||
1120
lib/seeds/weapons.csv
Normal file
1120
lib/seeds/weapons.csv
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue