Exception: ActiveRecord::InverseOfAssociationNotFoundError
- Inherits:
-
ActiveRecordError
- Object
- StandardError
- ActiveRecordError
- ActiveRecord::InverseOfAssociationNotFoundError
- Includes:
- DidYouMean::Correctable
- Defined in:
- lib/active_record/associations/errors.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#associated_class ⇒ Object
readonly
Returns the value of attribute associated_class.
-
#reflection ⇒ Object
readonly
Returns the value of attribute reflection.
Instance Method Summary collapse
- #corrections ⇒ Object
-
#initialize(reflection = nil, associated_class = nil) ⇒ InverseOfAssociationNotFoundError
constructor
A new instance of InverseOfAssociationNotFoundError.
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/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.[: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 ⇒ Object (readonly)
Returns the value of attribute associated_class.
34 35 36 |
# File 'lib/active_record/associations/errors.rb', line 34 def associated_class @associated_class end |
#reflection ⇒ Object (readonly)
Returns the value of attribute reflection.
34 35 36 |
# File 'lib/active_record/associations/errors.rb', line 34 def reflection @reflection end |
Instance Method Details
#corrections ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File '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.[:inverse_of].to_s) end else [] end end |