app/models/tenant.rb
# validates that there is only one tree
validates that there is only one tree
validates that there is only one tree
def validate_only_one_root
    unless parent_id || parent
      root = self.class.root_tenant
      errors.add(:parent, "required") if root && root != self
    end
  end
def validate_only_one_root unless parent_id || parent root = self . class . root_tenant errors . add ( :parent , "required" ) if root && root != self end end
validates that there is only one tree
validates that there is only one tree