Class: ActiveRecord::DataIntegrity::Validation::Presence
- Defined in:
- lib/active_record/data_integrity/cop/validation/presence.rb
Overview
Checks foreign key presence to the parent table of belongs_to association
Instance Attribute Summary
Attributes inherited from Cop
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
#call ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/active_record/data_integrity/cop/validation/presence.rb', line 10 def call results = validators.map do |validator| validator.attributes.map do |attribute| valid?(attribute) end end.flatten results.none?(&:!) end |