Итак, мой вопрос: как сделать возможным, чтобы звонки:
Clan.win #to get all won rounds
Clan.blue #to get all rounds when clan was in blue team
или даже вот так:
Clan.matches_win #need to calculate which team won match by counting rounds
Clan.matches_lost
Круглая модель:
class Round < ActiveRecord::Base
belongs_to :match
has_and_belongs_to_many :banned_champions, :class_name => "Champion", :join_table => "banned_champions_rounds"
belongs_to :clan_blue, :class_name => "Clan", :foreign_key => "clan_blue_id"
belongs_to :clan_purple, :class_name => "Clan", :foreign_key => "clan_purple_id"
belongs_to :winner, :class_name => "Clan", :foreign_key => "winner_id"
end
Модель клана:
class Clan < ActiveRecord::Base
has_many :players
has_many :rounds
end
Модель матча:
class Match < ActiveRecord::Base
has_many :rounds
end