Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在 Rails 中创建一个社交网络。我有一个用户模型和一个页面模型。用户可以“关注”或订阅页面。所以一个用户可以有很多页面,一个页面可以有很多用户。这些关系如何存储在数据库中?我是否需要创建一个属于_to :user 的新对象订阅?
通常这是通过一个“连接模型”(即 UserPage)和一个 user_pages 表来完成的。如果您愿意,您可以将其称为订阅,但 Rails 会奖励您坚持其预期的语义。