[英]Rails request where relation created_at lower than?
我需要选择所有的Authors
,其中Comments
和Posts
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.