1
0

More than 3 years have passed since last update.

[Ruby]作成されてから〇〇以上経ったレコードのみ取得・選択する方法

Posted at

作成されてから〇〇以上経ったレコードのみ取得・選択する方法

結論

Record.where('created_at < ?', 1.minute.ago).order(created_at: :desc)

重要なのは('created_at < ?', 〇〇)

〇〇に好きな条件を入れるだけ。

1時間前なら1.hour.ago
1日前なら1.day.ago

質問

クオーテーション使わない方法やベタープラクティスってありますか?

意外と見つけづらい情報でした。。。

1
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0