Class: ActiveRecord::DataIntegrity::Validation::Inclusion

Inherits:
Cop
  • Object
show all
Defined in:
lib/active_record/data_integrity/cop/validation/inclusion.rb

Overview

Checks foreign key presence to the parent table of belongs_to association

Instance Attribute Summary

Attributes inherited from Cop

#model

Instance Method Summary collapse

Methods inherited from Cop

cop_name, #initialize, #log, #progress

Constructor Details

This class inherits a constructor from ActiveRecord::DataIntegrity::Cop

Instance Method Details

#callObject



10
11
12
13
14
15
16
17
18
# File 'lib/active_record/data_integrity/cop/validation/inclusion.rb', line 10

def call
  results = validators.map do |validator|
    validator.attributes.map do |attribute|
      valid?(attribute)
    end
  end.flatten

  results.none?(&:!)
end