日時の範囲でクエリを行う
yesterday = Time.zone.yesterday Post.where(created_at: yesterday.beginning_of_day..yesterday.end_of_day ) Post.where(created_at: yesterday.all_day)
time_with_zone.beginning_of_day..time_with_zone.end_of_day
は time_with_zone.all_day
と書ける。
参考:
ActiveRecordで日付・時刻の範囲検索をシンプルに書く方法 | TechRacho