rails fields_for does not render after validation error on nested form

后端 未结 3 506
栀梦
栀梦 2020-12-16 22:27

I have a nested form problem. I implemented the nested forms solution form the railscasts 196 & 197. It works if I have no validation errors.

So, form renders pe

3条回答
  •  一生所求
    2020-12-16 23:19

    Does it throw an error?

    My guess is your problem is that in your new action, you are doing @property.images.build, which is not in your edit action. When the validation fails, it will render your new action, but won't run your new action. You could try putting @property.images.build in the else clause of your create action like:

    else
      @property.images.build
      render :action => 'new'
    end
    

    Not the cleanest way to do it, by any means, but this will help track down if that is your issue.

提交回复
热议问题