From 5041f03e272e9e1f3726b5f6b21b3d45cd78dd22 Mon Sep 17 00:00:00 2001 From: David Gay Date: Tue, 25 May 2021 20:00:32 -0400 Subject: Improve hearth view and amenity construction process --- app/models/hearth_amenity.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app/models') 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 -- cgit v1.2.3