Rails ORM Help

In my scenario, I have two tables namely; contacts and contacts_users.
Table contacts consists of a primary key namely id and contacts_users
has fields; id, contact_id, peer_id and status.

contacts_users is basically the recursive relation of a contact to its
peers, which he/she invited and vice versa. In other words, in one case,
the id of a person lies in the contact_id field of contacts_users and in
other case the id of same person lies in peer_id field. Moreover,
peer_id and contact_id of contacts_users constitute a composite key. So,
in contacts_users model i defined the said scenario like;
validate_uniqueness_of :contact_id, :scope=>peer_id
Which means; if A adds B, then A is a contact of B and B is a contact of
A as well, and the relation cannot be replicated.

Now what could be the relation of contacts_users and contacts tables, so
that I could do contacts.contacts_users and get all the contacts of
person A rather doing ContactsUsers.find_by_contact_id_or_peer_id?

Please Help.

You could look for a Gem that handles Friendship. There are a few.

You could use and ORM called datamapper

On Mon, May 18, 2009 at 4:31 PM, Abm Abm