I have two models: Player and Event with two join tables between them, participants and lessons.
class Event
has_many :participants
has_many :players, through: :participants
has_many :lessons
has_many :players, through: :lessons
end
class Player
has_many :participants
has_many :events, through: :participants
has_many :lessons
has_many :events, through: lessons
end
Not all events have lessons but all events have participants hence why I split the join table into two.
The problem is that if I were to do @player.events the resulting query would use the lessons join table instead of the participants.
Is there a better way to do this this?
EDIT: Here are the join table models:
class Lesson
belongs_to :player
belongs_to :event
end
class Participant
belongs_to :player
belongs_to :event
end