开发者

In a Facebook-like social network programmed in Rails, where in the database would you store that a user "likes" a Page?

开发者 https://www.devze.com 2023-02-08 20:27 出处:网络
I\'m creating a social network in Rails. I have a User model and a Page model. Users can \"follow\" or subscribe to Pages. So a user can have many pages and a page can have many users. How wou开发者_高

I'm creating a social network in Rails. I have a User model and a Page model. Users can "follow" or subscribe to Pages. So a user can have many pages and a page can have many users. How wou开发者_高级运维ld these relationships be stored in the database? Do I need to create a new object Subscription which belongs_to :user?


Generally this is done with a "join model", which would be UserPage, and a user_pages table. You could call it Subscription if you wanted, but Rails will reward you for sticking to its expected semantics.

0

精彩评论

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

关注公众号