method

covered_by_unique_index?

Importance_0
v8.1.1 - Show latest stable - 0 notes - Class: ActiveRecord::Validations::UniquenessValidator
covered_by_unique_index?(klass, record, attribute, scope) private

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/validations/uniqueness.rb, line 83
      def covered_by_unique_index?(klass, record, attribute, scope)
        @covered ||= self.attributes.map(&:to_s).select do |attr|
          attributes = scope + [attr]
          attributes = resolve_attributes(record, attributes)

          klass.schema_cache.indexes(klass.table_name).any? do |index|
            index.unique &&
              index.where.nil? &&
              (Array(index.columns) - attributes).empty?
          end
        end

        @covered.include?(attribute.to_s)
      end
Register or log in to add new notes.