Save collection of updated records all at once

前端 未结 2 681
花落未央
花落未央 2021-01-04 22:50

As I understand it, the build method can be used to build up a collection of associated records before saving. Then, when calling save, all the chi

2条回答
  •  清歌不尽
    2021-01-04 23:15

    Try using validates_associated :some_child_records in your Patient class.

    If you only want this to occur on updates, just use the :on option like validates_associated :some_child_records, :on => :update

    More info here:

    • http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#method-i-validates_associated

提交回复
热议问题