开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜