-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
A good example can be seen by modifying spec/app/models/person.rb as follows:
diff --git a/spec/app/models/person.rb b/spec/app/models/person.rb index b793b23..c20b927 100644 --- a/spec/app/models/person.rb +++ b/spec/app/models/person.rb @@ -5,6 +5,7 @@ class Person class_attribute :somebody_elses_important_class_options self.somebody_elses_important_class_options = { keep_me_around: true } + field :_id, default: ->{ ssn } field :title field :terms, type: Boolean field :pets, type: Boolean, default: false
Then I see spec failures such as:
1) Mongoid::Relations::Referenced::Many#<< when the relations are not polymorphic when appending in a parent create block persists the link
Failure/Error: person.reload.posts.should eq([ post ])
ArgumentError:
please also supply the unmatched ids
# ./lib/mongoid/errors/document_not_found.rb:25:in `initialize'
# ./lib/mongoid/reloading.rb:21:in `new'
# ./lib/mongoid/reloading.rb:21:in `reload'
# ./spec/mongoid/relations/referenced/many_spec.rb:129:in `block (6 levels) in <top (required)>'
I believe using a :default option with field :_id should be supported, but the related model foreign key doesn't seem to get updated in that case.