Đường ray 4
Parent.includes(:child).where.not(children: {id: nil})
hoặc
Parent.joins(:child).distinct
Đường ray 3
Parent.joins(:child).distinct
Parent.includes(:child).where.not(children: {id: nil})
hoặc
Parent.joins(:child).distinct
Parent.joins(:child).distinct