123456789_123456789_123456789_123456789_123456789_

Exception: ActiveRecord::AssociationNotFoundError

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

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(record = nil, association_name = nil) ⇒ AssociationNotFoundError

[ GitHub ]

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

def initialize(record = nil, association_name = nil)
  @record           = record
  @association_name = association_name
  if record && association_name
    super("Association named '#{association_name}' was not found on #{record.class.name}; perhaps you misspelled it?")
  else
    super("Association was not found.")
  end
end

Instance Attribute Details

#association_name (readonly)

[ GitHub ]

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

attr_reader :record, :association_name

#record (readonly)

[ GitHub ]

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

attr_reader :record, :association_name

Instance Method Details

#corrections

[ GitHub ]

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

def corrections
  if record && association_name
    @corrections ||= begin
      maybe_these = record.class.reflections.keys
      DidYouMean::SpellChecker.new(dictionary: maybe_these).correct(association_name)
    end
  else
    []
  end
end