Re: [Rails-core] conditional eager loading

2012-10-05 Thread r1git
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 inste

Re: [Rails-core] conditional eager loading

2012-10-04 Thread Corey Haines
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 On Thu, Oct 4, 2012 at 3:44 PM, r1git wrote: > Does anybody know how to fix this

[Rails-core] conditional eager loading

2012-10-04 Thread r1git
Does anybody know how to fix this issue: https://github.com/rails/rails/issues/4677 ? It seems so basic and yet there is no clean solution like conditional eager loading, something like: Shift.includes(:schedules).where(:schedules => { :occurs_on => Date.today }) Or another solution would be