diff --git a/lib/mongoid/association/embedded/embeds_many/proxy.rb b/lib/mongoid/association/embedded/embeds_many/proxy.rb index 9d5d0f7cfb..afcc7e7e4b 100644 --- a/lib/mongoid/association/embedded/embeds_many/proxy.rb +++ b/lib/mongoid/association/embedded/embeds_many/proxy.rb @@ -313,9 +313,12 @@ def destroy_all(conditions = {}) # # @return [ true | false ] True if persisted documents exist, false if not. def exists?(id_or_conditions = :none) - return _target.any?(&:persisted?) if id_or_conditions == :none - - criteria.exists?(id_or_conditions) + case id_or_conditions + when :none then _target.any?(&:persisted?) + when nil, false then false + when Hash then where(id_or_conditions).any?(&:persisted?) + else where(_id: id_or_conditions).any?(&:persisted?) + end end # Finds a document in this association through several different