Excuse me I was a little off. Your League table doesn’t need to have a
league_positions_id.
The problem is that LeaguePositions knows that it is connected to
Leagues by tournament_id. But Leagues think that the key that connects
a LeaguePositions to it is called league_positions_id.
this can be fixed in two ways #1
class League < Tournament
has_many :league_positions, :order => :position, :dependent =>
:destroy, :class => ‘LeaguePositions’, :foreign_key => ‘tournament_id’
end
OR
#2
change the foreign key in LeaguePositions from being tournament_id to
being league_id. Then change that line in the LeaguePositions class.
#1
class League < Tournament
has_many :league_positions, :order => :position, :dependent =>
:destroy, :class => ‘LeaguePositions’, :foreign_key => ‘tournament_id’
end
I’ve chosen the 2nd option, it works, but I had thought that declaring
the :foreign_key and
:class_name at belongs_to relationship in LeaguePosition model was
enough to tell the framework
how the relationship is.
Thanks!
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.