I have two models: Player and Event with two join tables between them, participants and lessons.
class Event
has_many :participants
has_many :players, th
You can use the class_name option to change the name of one of the has_many associations but still associate with the other class. In my example I am using students
for players
on an event
through lessons
, and lectures
for events
on a player
through lessons
. But what you name them can be different.
class Event
has_many :participants
has_many :players, through: :participants
has_many :lessons
has_many :students, through: :lessons, class_name: "Player"
end
class Player
has_many :participants
has_many :events, through: :participants
has_many :lessons
has_many :lectures, through: lessons, class_name: "Event"
end