Exception: ActiveRecord::HasManyThroughAssociationNotFoundError
- Inherits:
-
ActiveRecordError
- Object
- StandardError
- ActiveRecordError
- ActiveRecord::HasManyThroughAssociationNotFoundError
- Includes:
- DidYouMean::Correctable
- Defined in:
- lib/active_record/associations/errors.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#owner_class ⇒ Object
readonly
Returns the value of attribute owner_class.
-
#reflection ⇒ Object
readonly
Returns the value of attribute reflection.
Instance Method Summary collapse
- #corrections ⇒ Object
-
#initialize(owner_class = nil, reflection = nil) ⇒ HasManyThroughAssociationNotFoundError
constructor
A new instance of HasManyThroughAssociationNotFoundError.
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/active_record/associations/errors.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.[:through].inspect} in model #{owner_class.name}") else super("Could not find the association.") end end |
Instance Attribute Details
#owner_class ⇒ Object (readonly)
Returns the value of attribute owner_class.
75 76 77 |
# File 'lib/active_record/associations/errors.rb', line 75 def owner_class @owner_class end |
#reflection ⇒ Object (readonly)
Returns the value of attribute reflection.
75 76 77 |
# File 'lib/active_record/associations/errors.rb', line 75 def reflection @reflection end |
Instance Method Details
#corrections ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/active_record/associations/errors.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.[:through].to_s) end else [] end end |