Answers for "rails people parent child relation example"

0

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
Posted by: Guest on December-22-2020

Code answers related to "rails people parent child relation example"

Browse Popular Code Answers by Language