accepts_nested_attributes_for child association validation failing

后端 未结 6 2052
隐瞒了意图╮
隐瞒了意图╮ 2020-12-02 07:02

I\'m using accepts_nested_attributes_for in one of my Rails models, and I want to save the children after creating the parent.

The form works perfectly, but the vali

6条回答
  •  再見小時候
    2020-12-02 08:03

    Unfortunately none of the above suggestions work for me with Rails 2.3.5.

    In my case, the project in a task is always nil if both are created using nested attributes. Only if I remove the validates_presence_of, the create goes through successfully. The unit test and the log show that all is created correctly.

    So I'd now tend to add constraints to the DB instead of Rails as that seems to be more reliable in the first place.

提交回复
热议问题