diff options
author | David Gay <david@davidgay.org> | 2021-07-11 15:29:55 -0400 |
---|---|---|
committer | David Gay <david@davidgay.org> | 2021-07-11 15:31:44 -0400 |
commit | 8fa45ddfe700d603403b4102ee4797ebebbfcfd2 (patch) | |
tree | f114402f0cb177795711bcd01bdd473e5dde52fd /db | |
parent | 4ccb179056c990df5f60e574781d5ed57191c263 (diff) |
Allow for splitting activites and items data files into multiple files, and start doing so
Diffstat (limited to 'db')
-rw-r--r-- | db/seeds.rb | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/db/seeds.rb b/db/seeds.rb index 1e2888a..a513ee1 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -25,9 +25,11 @@ load_data_file("data/skills.yml").map do |gid, hash| skill.update(hash) end -load_data_file("data/items.yml").map do |gid, hash| - item = Item.find_or_create_by(gid: gid) - item.update(hash) +Dir["data/items/*"].each do |file_name| + load_data_file(file_name).map do |gid, hash| + item = Item.find_or_create_by(gid: gid) + item.update(hash) + end end load_data_file("data/locations.yml").map do |gid, hash| @@ -35,11 +37,13 @@ load_data_file("data/locations.yml").map do |gid, hash| location.update(hash) end -load_data_file("data/activities.yml").map do |gid, hash| - activity = Activity.find_or_create_by(gid: gid) - activity.assign_attributes(hash.except(:location)) - activity.location = Location.find_by_gid(hash[:location]) - activity.save +Dir["data/activities/*"].each do |file_name| + load_data_file(file_name).map do |gid, hash| + activity = Activity.find_or_create_by(gid: gid) + activity.assign_attributes(hash.except(:location)) + activity.location = Location.find_by_gid(hash[:location]) + activity.save + end end load_data_file("data/hearth_amenities.yml").map do |gid, hash| |