Has_many :though multiple times?


Apologies if this question has been answered before - I've looked
through the list and couldn't find anything answering my question.

Suppose I have users and skills, and I want to link the two through two
join models, one for skills a user has, another for skills a user wants
to improve.

I can get has_many :though working for one join model, but I don't know
how to get the other one working because you can't use :class_name or
:foreign_key - I looked at :source but that doesn't seem to do what I
need (but I could be wrong).


class User
  # ...

class Skill
  # This one is fine
  has_many :skill_ratings
  has_many :users, :through => :ratings

  has_many :skill_requests
  # What do I add here to make requestees use the User model and
user_id key?
  has_many :requestees, :through => :requests

class SkillRequest
  belongs_to :user
  belongs_to :skill

class SkillRating
  belongs_to :user
  belongs_to :skill

Any thoughts - or can you not do this with has_many :through and have
to manually create the joins yourself?


apologies that line should be:

has_many :requestees, :through => :skill_requests

Apologies once again

Apparently :source _is_ what is required to do this. I think the
examples that I have seen have implied that the source must be
something that you have already ":has_manyed".

So the line is:

has_many :requestees, :though => :skill_requests, :source => :user

I'll go and crawl into a small pit of shame for semi-spamming the list
now :frowning: