summaryrefslogtreecommitdiff
path: root/db/seeds.rb
diff options
context:
space:
mode:
authorDavid Gay <david@davidgay.org>2021-05-03 18:29:04 -0400
committerDavid Gay <david@davidgay.org>2021-05-03 18:29:04 -0400
commit23178917e0d415ac17aab9a8077a124c3254f124 (patch)
tree26c60ed872b382b0610e050ea19a921879d9d49a /db/seeds.rb
parent9729982e242b125579a996ff59579a906984c476 (diff)
Add Locations
Diffstat (limited to 'db/seeds.rb')
-rw-r--r--db/seeds.rb13
1 files changed, 9 insertions, 4 deletions
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