私の2つのモデル:
Class TeamHistory < ActiveRecord::Base
has_many :player_to_team_histories
has_many :players, through: :player_to_team_histories
belongs_to :team
end
Class Player < ActiveRecord::Base
has_many :player_to_team_histories
has_many :team_histories, through: :player_to_team_histories
end
player_to_team_histories
を使用して を作成することはできませんが、@team_history.players.build
正常に動作します@team_history.players.create
>>team = Team.create
>>team_history = team.team_histories.create
>>player = team_history.players.create
>>player.team_histories.count
1
>>player2 = team_history.players.build
>>player2.team_histories.count
0
>>player2.save
>>player2.team_histories.count
0