123456789_123456789_123456789_123456789_123456789_

Exception: ActiveRecord::InverseOfAssociationNotFoundError

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, ActiveRecordError, StandardError
Instance Chain:
self, DidYouMean::Correctable, ActiveRecordError, StandardError
Inherits: ActiveRecord::ActiveRecordError
Defined in: activerecord/lib/active_record/associations/errors.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(reflection = nil, associated_class = nil) ⇒ InverseOfAssociationNotFoundError

[ GitHub ]

  
# File 'activerecord/lib/active_record/associations/errors.rb', line 36

def initialize(reflection = nil, associated_class = nil)
  if reflection
    @reflection = reflection
    @associated_class = associated_class.nil? ? reflection.klass : associated_class
    super("Could not find the inverse association for #{reflection.name} (#{reflection.options[:inverse_of].inspect} in #{associated_class.nil? ? reflection.class_name : associated_class.name})")
  else
    super("Could not find the inverse association.")
  end
end

Instance Attribute Details

#associated_class (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/associations/errors.rb', line 34

attr_reader :reflection, :associated_class

#reflection (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/associations/errors.rb', line 34

attr_reader :reflection, :associated_class

Instance Method Details

#corrections

[ GitHub ]

  
# File 'activerecord/lib/active_record/associations/errors.rb', line 49

def corrections
  if reflection && associated_class
    @corrections ||= begin
      maybe_these = associated_class.reflections.keys
      DidYouMean::SpellChecker.new(dictionary: maybe_these).correct(reflection.options[:inverse_of].to_s)
    end
  else
    []
  end
end