I'm trying the list my parent and children of my Model "Performance Indicators", in my model I have this for parent/children:
  belongs_to :parent, class_name: "PerformanceIndicator", :foreign_key => 'parent_id2'
  has_many :children, class_name: "PerformanceIndicator", :foreign_key => 'parent_id2'
and in my performance indicators table I have the column parent_id2: t.integer  "parent_id2"
But if I try to call the parent like this for example: PerformanceIndicator.parent, its returning "Object", and if I try for the children it says #<NoMethodError: undefined method children' for
What am I doing wrong?
I want to list the performance indicators something like this:
Parent1
  Children1
  Children2
Parent2
  Children1
EDIT:
this is my performance indicators model:
class PerformanceIndicator < ActiveRecord::Base
  has_many :improvement_actions
  has_ancestry
  belongs_to :parent, class_name: "PerformanceIndicator"#, :foreign_key => :parent_id2
  has_many :children, class_name: "PerformanceIndicator", :foreign_key => 'parent_id2'
  scope :parents, -> { where('parent_id2=''') }
  def self.search(search)
    where("name iLIKE ? OR description iLIKE ?", "%#{search}%", "%#{search}%")
    # where("description LIKE ?", "%#{search}%")
  end
end