Lets take the "shortenend" example from
http://mongoid.org/docs/associations/
class Person
include Mongoid::Document
references_one :policy
end
class Policy
include Mongoid::Document
field :policy, :type => Integer, :default => 1
referenced_in :person
end
racksh/console
person = Person.create
policy = Policy.create
person.policy = policy
Everything works fine here.
The policy gets referenced via person_id.
But in mongodb I get:
person_id: null
policy : null
The person_id and the default value are not persisted to mongodb!
the oid for policy is there.
If I change everything to references_many it works fine but not with
references_one
Using:
ruby1.9.2 newest
mongoid 2.0.0.beta16
mongodb1.6