Better validates_associated method for Rails 3?

后端 未结 4 737
猫巷女王i
猫巷女王i 2021-02-04 03:47

Rails 3 includes the validates_associated which is automatically called when saving a nested model. The problem with the method is the message is terrible - \"Mode

4条回答
  •  北恋
    北恋 (楼主)
    2021-02-04 04:35

    validates_associated runs the validations specified in the associated object's class. Errors at the parent class level simply say 'my child is invalid'. If you want the details, expose the errors on the child object (at the level of the child's form in the view).

提交回复
热议问题