【发布时间】:2015-04-20 16:08:43
【问题描述】:
假设我有一个 Mongoid 模型,如下:
class Person
# stuff here
has_and_belongs_to_many :groups, :class_name => 'Group', :inverse_of => nil
end
我刚刚弃用了我的 Group 模型(完全摆脱了那个类),现在我想从我的所有 Person 模型中取消设置这种关系。
最合适的方法是什么?我知道 Mongoid 提供了一种取消设置字段的方法 (https://coderwall.com/p/wcx4pq/mongoid-remove-unnecessary-properties-from-documents),所以我想一定有一种方法可以对关系执行相同的操作,这样 Person 就不再有 groups 或 group_ids。
谢谢!
【问题讨论】: