@posts = Post.where(user_id:123).includes(:comments).where(comments: { created_at: Time.zone.today...Time.zone.tomorrow })
, добавить аналогичное условие, но по другому полю с использованием логических операторов?@posts = Post.where(user_id:123).includes(:comments).where(comments: { created_at: Time.zone.today...Time.zone.tomorrow } | comments: { created_at: Time.zone.today...Time.zone.tomorrow })
@posts = Post.where(user_id:123).includes(:comments).where("comments.created_at IN (?) OR comments.updated_at IN (?)", Time.zone.today...Time.zone.tomorrow, Time.zone.today...Time.zone.tomorrow)
Post.where(id: 1).or(Post.where(id: 2))
date = "2016-06-28"
@posts = Post.where(user_id: 123).includes(:comments).where("(comments.created_at BETWEEN ? AND ?) OR (comments.updated_at BETWEEN ? AND ?)", date, date.next, date ,date.next).references(:comments)