I have a two relations called Course and School.
Course also has a datetime field open_date.
I want to return all course where the school tier is not 1, and whithin a certain date.
I want some rails code like this:
Course.includes(:school).where("school.tier <> ? AND open_date between ? and ?",1 , date1, date2)
You were almost there:
The
joinsclause will eliminate the Courses without School associated.(if doesn’t work, try with
joins(:school))