class Activity < ApplicationRecord include HasWhatnot 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