RAILS - How to write a query that gets records created within 1 minute of each other

Viewed 101

I am new to rails and am unsure how to write a query that gets records created within 1 minute of each other. Any help would be appreciated.

1 Answers

you can use this query:

User.where(updated_at: (Time.now - 1.minutes)..Time.now)

In this query, you can pass time manually if you want to find records from the last 24 hours then you can use like this:

User.where(updated_at: (Time.now - 24.hours)..Time.now)
Related