Would merge work? Something like (off the top of my head):
Shift.includes(:schedules).merge(Schedule.occuring_on(Date.today))
where .occuring_on is
def self.occuring_on(day) where(:occurs_on => day) end
-Corey
Would merge work? Something like (off the top of my head):
Shift.includes(:schedules).merge(Schedule.occuring_on(Date.today))
where .occuring_on is
def self.occuring_on(day) where(:occurs_on => day) end
-Corey
Thank you for your suggestion, I tested it and it launches the same SQL request as
Shift.includes(:schedules).where("schedules.occurs_on = '#{Date.today}'")
which fails to return the shifts with no schedules or schedules not matching the condition. Because the where apply on the whole SQL instead of the JOIN condition.