2014-03-26 11:09:39 +00:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: gather_maps
|
|
|
|
#
|
|
|
|
# id :integer not null, primary key
|
2020-03-18 03:38:17 +00:00
|
|
|
# votes :integer
|
2014-03-26 11:09:39 +00:00
|
|
|
# gather_id :integer
|
|
|
|
# map_id :integer
|
2020-03-18 03:38:17 +00:00
|
|
|
#
|
|
|
|
# Indexes
|
|
|
|
#
|
|
|
|
# index_gather_maps_on_gather_id (gather_id)
|
|
|
|
# index_gather_maps_on_map_id (map_id)
|
2014-03-26 11:09:39 +00:00
|
|
|
#
|
|
|
|
|
2014-03-23 00:22:25 +00:00
|
|
|
class GatherMap < ActiveRecord::Base
|
2019-06-02 01:26:36 +00:00
|
|
|
scope :ordered, -> { order("votes DESC, id DESC") }
|
2014-03-23 00:22:25 +00:00
|
|
|
|
2020-03-26 02:26:30 +00:00
|
|
|
belongs_to :gather, :optional => true
|
|
|
|
belongs_to :map, :optional => true
|
2014-03-23 00:22:25 +00:00
|
|
|
has_many :real_votes, :class_name => "Vote", :as => :votable
|
|
|
|
|
|
|
|
before_create :init_variables
|
|
|
|
|
|
|
|
def to_s
|
|
|
|
self.map.to_s
|
2019-08-14 06:30:56 +00:00
|
|
|
end
|
2014-03-23 00:22:25 +00:00
|
|
|
|
|
|
|
def init_variables
|
|
|
|
self.votes = 0
|
|
|
|
end
|
|
|
|
end
|