0
我正在設計RoR中的基本運動應用程序,我不知道我的數據庫設計是否正確。舉例來說,我有:RoR DB Design - 我需要使用a:through表嗎?
class Game < ActiveRecord::Base
has_one :home_team
has_one :away_team
end
class Team < ActiveRecord::Base
has_many :games
end
然而,有人告訴我更好的方式來做到這一點是:
class Game < ActiveRecord::Base
has_many :teams, :through => :game_teams, :limit => 2
end
class Team < ActiveRecord::Base
has_many :games, :through => :game_teams
end
class Game_Teams < ActiveRecord::Base
belongs_to :game
belongs_to :team
end
是否有一個原因,我會或不會想無論是設計?