我有多个具有许多关联的类将它们链接在一起,我希望能够获取顶级对象,关闭它,并关闭所有子对象。我需要关闭每个对象,因为我希望能够选择任何父对象并关闭它的所有子对象。
例如(我意识到这可能不存在):
class Requisition
has_many :shipments, :dependent_method => :close
end
class Shipment
belongs_to :requisition
has_many :reroutes, :dependent_method => :close
end
class Reroute
belongs_to :shipment
has_many :deliveries, :dependent_method => :close
end
class Delivery
belongs_to :reroute
end
有人知道实现这一目标的好解决方案吗?宝石/插件是完全可以接受的:-)
非常感谢!