Check that delegated relation classes are defined before including
QueryMethods from them, to safeguard against changes in ActiveRecord.