summaryrefslogtreecommitdiff
path: root/app/models/activity.rb
blob: e70121e5ce69aecc635719e95610cc7548ff6af2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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