Records Created Yesterday in Rails

What is the activerecord call for finding all User created_at is yesterday?

To find all User records with a created_at timestamp of yesterday using ActiveRecord in Ruby on Rails, you can use the following code:

1
2
yesterday = Date.yesterday.beginning_of_day..Date.yesterday.end_of_day
users_created_yesterday = User.where(created_at: yesterday)

This code first creates a range representing yesterday’s date from the beginning of the day to the end of the day. Then, it queries the User model using the where method to filter the records based on the created_at timestamp within the specified range. The result is an ActiveRecord relation containing all User records created yesterday.