Answers for "rails STI Parent child relationship"

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 STI Parent child relationship"

Browse Popular Code Answers by Language