If I have a meet Model in Rails,now I want to get the record yesterday,how should I do?
Meet.where(:created_at=> ) # what should I write here?
Or ActiveRecord comes with some method to filter the yesterday record?
If I have a meet Model in Rails,now I want to get the record yesterday,how should I do?
Meet.where(:created_at=> ) # what should I write here?
Or ActiveRecord comes with some method to filter the yesterday record?
If you are using Rails 5.1 or later you can use all_day:
Meet.where(created_at: 1.day.ago.all_day)
also.. I suggest to define a scope like:
scope :yesterday, -> { where(created_at: 1.day.ago.all_day) }