parent child relationship rails
def get_ancestors(level = 0, result = [])
result.push([level, self])
if(!self.children.empty?)
self.children.each do |child|
child.get_ancestors(level+1, result)
end
end
if(level == 0)
return result
end
end