Ghjhdf
Ghjhdf

Reputation: 171

How to implement a follower system like Twitter with has_and_belongs_to_many association?

I am a novice of Rails. And I wanna create a tiny SNS like Twitter.
How to implement the follower system with AciveRecord in has_and_belongs_to_many?
I create a "User" table. And the follower relationship is a many-to-many logic between one user and one user.
So how to decelerate the model class and create the join table?

Upvotes: 0

Views: 825

Answers (1)

hsming
hsming

Reputation: 2528

The last chapter of railstutorial is talking about what you want. http://ruby.railstutorial.org/chapters/following-users#top

Upvotes: 1

Related Questions