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