best way to implement friendship thing?

I am new to rails and have to develop a small app which will do regular social networking. So, whats the best and efficient way to implement friends/friendship thing so that I could get complete list of every user's friends with @user.friends and also which is easy to maintain and implement.

Thanks.

Vapor .. wrote:

I am new to rails and have to develop a small app which will do regular social networking. So, whats the best and efficient way to implement friends/friendship thing so that I could get complete list of every user's friends with @user.friends and also which is easy to maintain and implement.

Thanks.   

You'll want to do a self referential 'has_many :through =>'.

A google search with just the right keywords (eg: self referential has_many through) should get you all the information you need, and then some.

Good Luck! And welcome to Rails.

Use the awesome plugin "has_many_friends": http://svn.dnite.org/has_many_friends/README

Hi Jon,

Take a look at this plugin. http://www.railslodge.com/plugins/40-has-many-friends

Jon Garvin wrote:

Scott A S wrote:

Hi Jon,

Take a look at this plugin. http://www.railslodge.com/plugins/40-has-many-friends

actually I want to sort of understand it...I mean how it all actually works with has_many => :through

The post I liked the most is:

http://www.fallenrogue.com/article/view/143-I-am-what-I-am-or-self-referential-joins-in-Rails

AWDWR and Rails Recipes also help a lot.

Cheers, Sazima

Check out RailsSpace book on Amazon: