belongs_to parent has many children
entries table id | parent_id
class Entry < ApplicationRecord belongs_to :parent, class_name: "Entry" has_many :children, class_name: "Entry"
Entry.last.children.last.parent
on different column name:
entries table id | parent_entry_id
class Entry < ApplicationRecord belongs_to :parent, class_name: "Entry", foreign_key: :parent_entry_id #, optional: true has_many :children, foreign_key: :parent_entry_id, class_name: "Entry"
Entry.last.children.last.parent