mongoid/mongoid — pull request #3817 by baqiuhong93 (2014-10-02 06:00:42+00:00)
Title: Cannot assign ids through accepts_nested_attributes_for #2644

class Question
include Mongoid::Document
embeds_many :options
accepts_nested_attributes_for :options, allow_destroy: true, reject_if: ->(attrs){ !attrs[:description].present? }
end

class Option
include Mongoid::Document
embedded_in :question
field :name, type: String
field :description, type: String
end

in console , when i execute this code:
question = Question.new({:options_attributes => {"0"=>{"id"=>"542cb0476c696e06b0000000", "name"=>"A", "description"=>"A Description"}, "1"=>{"id"=>"542cb0476c696e06b0010000", "name"=>"B", "description"=>"B Description"}}})

error message is: NoMethodError: undefined method `assign_attributes' for nil:NilClass