Trouble with accepts_nested_attributes_for in Rails 5.0.0.beta3, -api option
I also encountered the same problem.
It seems specification has been changed from Rails 5.
By putting the option, and the previous and the same operation.
belongs_to should default to required: true #18233
class Post < ApplicationRecord belongs_to :member, optional: trueend
It is my clumsy may speak English, but ...
This is a regression reported as rails#25198. As was pointed out, you may use inverse_of
as a workaround.
It is planned to be fixed in 5.0.1.
I had the same problem and I found the solution in https://github.com/rails/rails/issues/18233
Just add
class Post < ApplicationRecordbelongs_to :member, required: falseend
It seems a problem with accepts_nested_attributes_for
in Rails 5, so you need add required: false
to your child models.