Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Reflection: Find the target model of a through association #114
While working on porting
For regular non-through associations, I simply do
However, a through-association doesn't have a
It's not clear to me how I would find the actual targetted model through this.
In the example I'm working with—a HABTM-like setup—I have:
class Team include NoBrainer::Document has_many :team_fans has_many :fans, through: :team_fans end class Fan include NoBrainer::Document has_many :team_fans has_many :teams, through: :team_fans end class TeamFan include NoBrainer::Document belongs_to :team belongs_to :fan end
To give a clearer idea of what I'm trying to do, here's what I'm looking at in
I'm looking around for a way to access the
So you want to know the target_model of a has many through association if I understand correctly?
If so, you are not missing anything, there is no code traverse the associations like that.
Let me add a bit of code for that.