rails many to many self join -
Some can tell me in the right direction:
I try to make a model for rail Construction of the following:
Class AID
There are many "Class A" relations (hence it is a reference of itself)
I was looking for For the migration and model.
I'm not sure what the correct joining table is (I think this is a simple 2 column table class_id, classarial_id-> both point to the class) and how to construct a model <
I like something
class person & lt; ActiveRecord :: Base is has_many: friendship ,: foreign_key => "Person_id" ,: class_name = & gt; "Friendship" has moments: Friends ,: By & gt; : End Friendship of Friendship & lt; ActiveRecord :: Base is_to: person,: foreign_key = & gt; "Person_id" ,: class_name = & gt; "Person" belongs_to: friend,: foreign_key = & gt; "Friend_id" ,: class_name = & gt; "Person" will expire
and will be similar to tables
People: ID; Name; Whatever you need to befriend: ID; Person_id; Friend_id
Comments
Post a Comment