【发布时间】:2012-07-06 17:06:21
【问题描述】:
我是这样做的:
@disabled_options = []
Category.where('ancestry is NULL').each do |cat|
@disabled_options << cat.id if cat.has_children?
end
有没有更优雅的方法让所有的父母都没有孩子?
【问题讨论】:
-
您要查找所有“父母”(所有有孩子的类别)还是要查找所有“根”(所有没有父母的类别)?
-
所有有孩子的类别