开发者

Mongoid accepts_nested_attributes_for issue

开发者 https://www.devze.com 2023-03-29 21:05 出处:网络
I have got this relations class Bird include Mongoid::Document has_many :eggs accepts_nested_attributes_for :eggs

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

精彩评论

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