Rails 3 模型关联。限制所选数据的数量

发布于 2024-09-14 09:12:33 字数 156 浏览 2 评论 0原文

我有一个模范用户、一个提要和一条评论。用户有很多提要和评论,提要属于用户并有很多评论,最后评论属于用户和提要。

不,当我显示某个用户的提要时,它会选择每个提要迄今为止所做的所有评论。我希望它只选择过去 1 分钟内发表的评论,如果没有,我想显示最近的 2 条评论...我该怎么做???

I have a model user, a feed, and a comment. user has many feeds and comments, feeds belong to user and have many comments and finally comments belong to user and feed.

No when i show feeds for a certain user, it selects all the comments made till date for every feed. I want it to select only those comments that were made in the last 1 min, and if none were, i want to show the 2 most recent ones... how can i do that???

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文