class JobClassify < ApplicationRecord
  acts_as_list scope: :parent_id
  scope :root, -> { where parent_id: 0 }

  validates :name, presence: true

  has_many :childrens, class_name: 'JobClassify', foreign_key: 'parent_id', dependent: :destroy
  has_many :jobs, dependent: :restrict_with_error
  belongs_to :parent, class_name: 'JobClassify', foreign_key: 'parent_id', optional: true
end
