From 23178917e0d415ac17aab9a8077a124c3254f124 Mon Sep 17 00:00:00 2001 From: David Gay Date: Mon, 3 May 2021 18:29:04 -0400 Subject: Add Locations --- db/seeds.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'db/seeds.rb') diff --git a/db/seeds.rb b/db/seeds.rb index 00a0566..7fcd125 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -17,15 +17,20 @@ end load_data_file("data/items.yml").map do |gid, hash| item = Item.find_or_create_by(gid: gid) - item.name = hash[:name] - item.description = hash[:description] + item.assign_attributes(hash.except(:equip_slot, :usable)) item.equip_slot = hash[:equip_slot]&.to_sym item.usable = hash[:usable] || false - item.whatnot = hash[:whatnot] item.save end +load_data_file("data/locations.yml").map do |gid, hash| + location = Location.find_or_create_by(gid: gid) + location.update(hash) +end + load_data_file("data/activities.yml").map do |gid, hash| activity = Activity.find_or_create_by(gid: gid) - activity.update(hash) + activity.assign_attributes(hash.except(:location)) + activity.location = Location.find_by_gid(hash[:location]) + activity.save end -- cgit v1.2.3