How to determine if any field in a model / nested model changed?

后端 未结 4 1928
执笔经年
执笔经年 2020-12-25 10:45

Is there some quick way to find out if any of a model\'s fields or any fields of it\'s nested models (a.k.a. associations) changed?

4条回答
  •  情歌与酒
    2020-12-25 11:12

    I know this is old question but recently came across same situation.

    You can get all changes for your nested model using previous_changes method even after saving the object.

    parent_model_object.nested_model_name.previous_changes
    

    This will list all changes in the nested model along with old and new value.

提交回复
热议问题