Forum: Ruby on Rails Rails ORM Help

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
333c1e948859b7d7f111cabdac0db0f7?d=identicon&s=25 Abm Abm (adeel_bm)
on 2009-05-18 06:31
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.
4e3f0697007cdbb6129fe21a50e331e6?d=identicon&s=25 Steve Shepherd (Guest)
on 2009-05-18 07:15
(Received via mailing list)
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
This topic is locked and can not be replied to.