仅删除一个多对多关系 [英] Delete a Has-Many Relationship ONLY
本文介绍了仅删除一个多对多关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个:has_and_belongs_to_many :friends, :join_table => "friends_peoples".
要添加朋友,我要做的是:@people.followers << @friend
创建关系和新的个人资料.
To add a friend I do: @people.followers << @friend
which create the relationship and a new person profile.
现在我只想删除关系,而不是个人资料.
Now I'd like to delete the relationship ONLY and not the person profile.
我尝试了@people.friends.delete(guilty.id)
,但是它删除了个人资料,而不是关系.
I tried @people.friends.delete(guilty.id)
but it deletes the person profile and not the relationship.
有什么主意吗?
推荐答案
您尝试过吗?
@people.friends.delete(guilty)
这篇关于仅删除一个多对多关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文