2011-08-21 5 views
3

accepts_nested_attributes_for 나는이 관계Mongoid는 문제

내 계란은
class Bird 
    include Mongoid::Document 
    has_many :eggs 
    accepts_nested_attributes_for :eggs 
end 

class Egg 
    include Mongoid::Document 
    belongs_to :bird 
end 

bird = Bird.new 
#=> #<Bird... 
bird.eggs.build 
#=> #<Egg... 
bird.save 
bird.reload.eggs 
#=> [] 

를 가지고있다!

답변

4
has_many

has_many :eggs, :autosave => true 
변경