Has_many :though multiple times?

Hi,

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).

Example

class User

end

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
end

class SkillRequest
belongs_to :user
belongs_to :skill
end

class SkillRating
belongs_to :user
belongs_to :skill
end

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

TIA,
Roland

apologies that line should be:

has_many :requestees, :through => :skill_requests

On Dec 13, 4:58 pm, “Roland S.” [email protected]

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:

Cheers,
Roland

On Dec 13, 5:00 pm, “Roland S.” [email protected]