class Activity < ApplicationRecord include HasWhatnot belongs_to :location, optional: true validates :gid, :name, :description, presence: true def cost_string requirements = [] self.whatnot[:cost].each do |cost| case cost[:type] when "item" requirements.push "#{cost[:quantity]} #{Item.find_by_gid(cost[:gid]).name}" end end requirements.join(", ") end end