Class: ActiveRecord::DataIntegrity::BelongsTo::ForeignKey

Inherits:
Cop
  • Object
show all
Defined in:
lib/active_record/data_integrity/cop/belongs_to/foreign_key.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
# File 'lib/active_record/data_integrity/cop/belongs_to/foreign_key.rb', line 10

def call
  results = associations.map do |association|
    valid?(association)
  end

  results.none?(&:!)
end