开发者

Following functionality - database design problem - Rails 3

I need following functionality in my app (twitter like). One user can fallow other user. I开发者_运维百科 have model User, and I tried with self many-to-many relation, but I don't know how to implement this in my model.

Can you explain me some example how to do this?


Michael Hartl's tutorial has an entire section on follower relationships. I recommend reading it to get a better understanding of self many-to-many relations. It helped me a lot:

http://ruby.railstutorial.org/chapters/following-users

You could also use a gem like acts_as_follower, which abstracts much of the design details out for you:

https://github.com/tcocca/acts_as_follower

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜