0
: 가능하게하는 방법을 호출하는 :has_many 협회
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
,210
일치 모델 : 당신의 클랜 클래스에서
class Match < ActiveRecord::Base
has_many :rounds
end