I have a parent model that has many child models
我有一个有很多子模型的父模型
I want to destroy duplicate child records based on one parameter of the child.
我想根据孩子的一个参数销毁重复的子记录。
I tried this:
我试过这个:
parent.child.uniq! {|child| child.parameter }
It apparently works but the database does not reflects the change.
它显然有效,但数据库并没有反映出变化。
1 个解决方案
#1
1
Your operation is performed on an object retrieved from database and not the actual database. Check out this post for the right answer.
您的操作是对从数据库而不是实际数据库检索的对象执行的。看看这篇文章的正确答案。
#1
1
Your operation is performed on an object retrieved from database and not the actual database. Check out this post for the right answer.
您的操作是对从数据库而不是实际数据库检索的对象执行的。看看这篇文章的正确答案。