Mongoid accepts_nested_attributes_for issue
I have got this relations
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
#=> 开发者_C百科#<Bird...
bird.eggs.build
#=> #<Egg...
bird.save
bird.reload.eggs
#=> []
Where are my eggs!
Change the has_many
to
has_many :eggs, :autosave => true
精彩评论