accepts_nested_attributes_for child association validation failing

后端 未结 6 2060
隐瞒了意图╮
隐瞒了意图╮ 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 07:41

    Contrary to what bigo suggests, it's not always acceptable to save the parent object first and then the children. Usually you want to make sure all objects validate before you start saving them. That gives the user the chance to re-edit the input form and correct any errors.

    The problem you describe will be fixed in Rails 3.0. I would have posted a link to the Lighthouse ticket, but stackoverflow.com does not allow this because I'm a new user (#fail). But for the time being, you can use the plugin "parental_control", which will fix your "bug".

提交回复
热议问题