diff options
Diffstat (limited to 'app/models/activity.rb')
-rw-r--r-- | app/models/activity.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/app/models/activity.rb b/app/models/activity.rb index fb99e1d..e70121e 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -1,6 +1,16 @@ class Activity < ApplicationRecord include HasWhatnot - belongs_to :location + belongs_to :location, optional: true validates :gid, :name, :description, presence: true + + def cost_string + requirements = [] + data = self.whatnot[:cost] + return nil unless data + data[:items].each do |item_gid, quantity| + requirements.push "#{quantity} #{Item.find_by_gid(item_gid).name}" + end + requirements.join(", ") + end end |