lib/mongoid/relations/referenced/many_to_many.rb in mongoid-3.0.13 vs lib/mongoid/relations/referenced/many_to_many.rb in mongoid-3.0.14
- old
+ new
@@ -119,10 +119,11 @@
# @since 2.1.0
def delete(document)
doc = super
if doc && persistable?
base.pull(foreign_key, doc.id)
+ target._unloaded = criteria
unsynced(base, foreign_key)
end
doc
end
@@ -167,10 +168,14 @@
# @return [ Many ] The relation.
#
# @since 2.0.0.rc.1
def substitute(replacement)
purge
- push(replacement.compact.uniq) unless replacement.blank?
+ unless replacement.blank?
+ push(replacement.compact.uniq)
+ else
+ reset_relation_criteria
+ end
self
end
# Get a criteria for the documents without the default scoping
# applied.