Exception: ActiveRecord::InverseOfAssociationNotFoundError

Inherits:
ActiveRecordError show all
Includes:
DidYouMean::Correctable
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reflection = nil, associated_class = nil) ⇒ InverseOfAssociationNotFoundError

Returns a new instance of InverseOfAssociationNotFoundError.



36
37
38
39
40
41
42
43
44
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations.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_classObject (readonly)

Returns the value of attribute associated_class.



34
35
36
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations.rb', line 34

def associated_class
  @associated_class
end

#reflectionObject (readonly)

Returns the value of attribute reflection.



34
35
36
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations.rb', line 34

def reflection
  @reflection
end

Instance Method Details

#correctionsObject



49
50
51
52
53
54
55
56
57
58
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations.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