Rails 设计模式:一个分发列表类中的组和个人
我有一个用户类,它有很多事件并且属于很多组。我想允许用户创建活动并通过组、用户 ID 或两者来限制他想要邀请的人。
我正在考虑创建一个表 Invitee 来存储所有用户的 id 和事件 id。对于每个事件,当用户 A 选择邀请组 Z 以及用户 B 和 C 时,我将查询组 Z 以查找成员的所有用户 id,并将它们与 B 和 C 的用户 id 一起添加到 Invitee 表中。
我认为这可能不是最好的方法。我想知道是否有更好的方法来做到这一点。
谢谢。
I have a class User, which has many Events and belongs to many Groups. I want to allow user to create Event and restrict who he wants the invite by Group, by user id or by both.
I am thinking creating a table Invitee to store all users' id and events id. For each Event, when user A chooses to invite group Z and users B and C, I will query group Z to find all user id of the members and add them to Invitee table, together with B and C's user id.
I think it is might not be the best way to do it. I wonder if there is a better way to do it.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看多态关联:基本上您需要可以是任一实体类型的邀请。
Look in to polymorphic associations: basically you want invitations that can be either entity type.