Ruby on Rails在一个表中有很多很多

时间:2021-12-18 09:54:47

In my Ruby on Rails project, I have a Users table where each of them can tweet a tiny post to a group and people follows groups instead of single person. What i'd like to do is to create a blackList - meaning Person A can choose never to get tweets from person B (although they are both members of the same group). The way of doing many to many in RoR is actually very easy - "has_many XXXX through YYYY", but in this case i need to use the users table twice for each "pair" of blackList item.

在我的Ruby on Rails项目中,我有一个用户表,其中每个人都可以向一个组发送一条微博,而人们会跟随一个组而不是一个人。我想做的是创建一个黑名单——这意味着a可以选择不从B那里获取tweet(尽管他们都是同一组的成员)。对RoR中的许多用户执行“many to many”的方法实际上非常简单——“has_many XXXX to yyy”,但是在这种情况下,我需要对每个黑名单项的“pair”使用users表两次。

Any idea how to do such a thing?

你知道怎么做这种事吗?

1 个解决方案

#1


1  

This railscast shows how to model friend-following in a social network app as a self-referential association.

这个railscast展示了如何在一个社交网络应用程序中作为一个自我参照的关联来建模friendfeed。

#1


1  

This railscast shows how to model friend-following in a social network app as a self-referential association.

这个railscast展示了如何在一个社交网络应用程序中作为一个自我参照的关联来建模friendfeed。