Sorry if this has been posted elsewhere, not sure what to search for.
I have this query that is currently using .select
, but there must be a better way to get the same result without using the dreaded .select
? The mission is: find all shift cancellations that were created within 6 hours of when the shift was supposed to start:
ShiftCancellation.select{|c| c.created_at > c.shift.date_time - 6.hours}
ShiftCancellation belongs_to :shift
and vice versa.
I'm on Postgres, so SQL-exclusive queries won't work.