-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
class Parent include Mongoid::Document field :surname, :type => String has_many :children, :dependent => :destroy end class Child include Mongoid::Document belongs_to :parent field :surname, :type => String, :default => lambda { parent.surname if parent } end parent = Parent.create!(:surname => "Bond") p Child.new(:parent => parent).surname # "Bond" :D p parent.children.build.surname # nil :(
The behaviour of Child.new(:parent => parent) and parent.children.build ought to be the same.