Filter ActiveRecord relations on attributes, associations, and custom scopes using a set of common logical operators