I need to get records created 30 minutes ago from Time.now
. I'm using a cron and I want to fire the cron once ever minute.
I essentially need this except it should ignore the seconds so that if Time.now == Wed, 31 Jan 2018 18:00:31 +0000
then a record with created_at = "Wed, 31 Jan 2018 17:30:23 +0000
should match.
Here is the query I have so far which doesn't work because the time is improperly evaluated.
Cart.joins(:cart_addresses).group('carts.id').where(created_at: Time.now - 30.minutes).each do |i|
puts i.id
end