Exception: ActiveRecord::HasManyThroughAssociationNotFoundError

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(owner_class = nil, reflection = nil) ⇒ HasManyThroughAssociationNotFoundError

Returns a new instance of HasManyThroughAssociationNotFoundError.



77
78
79
80
81
82
83
84
85
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations.rb', line 77

def initialize(owner_class = nil, reflection = nil)
  if owner_class && reflection
    @owner_class = owner_class
    @reflection = reflection
    super("Could not find the association #{reflection.options[:through].inspect} in model #{owner_class.name}")
  else
    super("Could not find the association.")
  end
end

Instance Attribute Details

#owner_classObject (readonly)

Returns the value of attribute owner_class.



75
76
77
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations.rb', line 75

def owner_class
  @owner_class
end

#reflectionObject (readonly)

Returns the value of attribute reflection.



75
76
77
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations.rb', line 75

def reflection
  @reflection
end

Instance Method Details

#correctionsObject



90
91
92
93
94
95
96
97
98
99
100
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations.rb', line 90

def corrections
  if owner_class && reflection
    @corrections ||= begin
      maybe_these = owner_class.reflections.keys
      maybe_these -= [reflection.name.to_s] # remove failing reflection
      DidYouMean::SpellChecker.new(dictionary: maybe_these).correct(reflection.options[:through].to_s)
    end
  else
    []
  end
end