summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorDavid Gay <david@davidgay.org>2021-05-25 20:00:32 -0400
committerDavid Gay <david@davidgay.org>2021-05-25 20:00:32 -0400
commit5041f03e272e9e1f3726b5f6b21b3d45cd78dd22 (patch)
treefa48400f25952a0c4ed50c4c5f0fe8ce24405284 /app/models
parentf4122067ce58b595c8ccfbe61cbe082f25648415 (diff)
Improve hearth view and amenity construction process
Diffstat (limited to 'app/models')
-rw-r--r--app/models/hearth_amenity.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/app/models/hearth_amenity.rb b/app/models/hearth_amenity.rb
index f8ebad5..a5dde23 100644
--- a/app/models/hearth_amenity.rb
+++ b/app/models/hearth_amenity.rb
@@ -4,6 +4,8 @@ class HearthAmenity < ApplicationRecord
validates :gid, :name, :description, presence: true
def construct_activity(level)
- Activity.find_by_gid("construct_#{self.name.underscore}_level#{level}")
+ activity_data = self.whatnot[:construct_activities].find { |a| a[:level] == level }
+ return nil unless activity_data
+ Activity.find_by_gid(activity_data[:gid])
end
end