如果我想要一份周日开放的所有商店的清单,我会
Shop.includes(:opening_times).where("opening_times.day =?", 'Sunday')
有没有办法获得周日关闭的所有商店的清单?也就是说,所有与日期栏都是“星期天”的记录无关的商店?
答案 0 :(得分:2)
sun_open = Shop.includes(:opening_times).where("opening times.day = ?", "Sunday").ids;
sunday_closed = Shop.where("id NOT IN (?)", sunday_open);