lib/mongoid/relations/referenced/many_to_many.rb in mongoid-4.0.0 vs lib/mongoid/relations/referenced/many_to_many.rb in mongoid-4.0.1
- old
+ new
@@ -53,16 +53,16 @@
ids, docs, inserts = {}, [], []
documents.each do |doc|
next unless doc
append(doc)
if persistable? || _creating?
- ids[doc.id] = true
+ ids[doc._id] = true
save_or_delay(doc, docs, inserts)
else
existing = base.send(foreign_key)
- unless existing.include?(doc.id)
- existing.push(doc.id) and unsynced(base, foreign_key)
+ unless existing.include?(doc._id)
+ existing.push(doc._id) and unsynced(base, foreign_key)
end
end
end
if persistable? || _creating?
base.push(foreign_key => ids.keys)
@@ -88,11 +88,11 @@
# @return [ Document ] The new document.
#
# @since 2.0.0.beta.1
def build(attributes = {}, type = nil)
doc = Factory.build(type || klass, attributes)
- base.send(foreign_key).push(doc.id)
+ base.send(foreign_key).push(doc._id)
append(doc)
doc.apply_post_processed_defaults
unsynced(doc, inverse_foreign_key)
yield(doc) if block_given?
doc
@@ -132,10 +132,10 @@
def nullify
target.each do |doc|
execute_callback :before_remove, doc
end
unless __metadata.forced_nil_inverse?
- criteria.pull(inverse_foreign_key => base.id)
+ criteria.pull(inverse_foreign_key => base._id)
end
if persistable?
base.set(foreign_key => base.send(foreign_key).clear)
end
after_remove_error = nil