繁体   English   中英

Rails请求的关系created_at低于哪里?

[英]Rails request where relation created_at lower than?

我需要选择所有的Authors ,其中CommentsPosts created_at低于some time

Author.include(:comments, :posts).
       where(comments: { created_at < 8.hours,ago}, posts: { created_at< 8.hours.ago } )`

作者可能没有任何评论或帖子。 我怎样才能做到这一点?

这样可以在任何特定模型中查找最近创建的对象:

Model.where(created_at: 5.days.ago..Time.current)

也许这可以有所帮助

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM