Class: ActiveRecord::AssociationNotFoundError::Correction

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/associations.rb

Instance Method Summary collapse

Constructor Details

#initialize(error) ⇒ Correction

Returns a new instance of Correction.



20
21
22
# File 'lib/active_record/associations.rb', line 20

def initialize(error)
  @error = error
end

Instance Method Details

#correctionsObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/active_record/associations.rb', line 24

def corrections
  if @error.association_name
    maybe_these = @error.record.class.reflections.keys

    maybe_these.sort_by { |n|
      DidYouMean::Jaro.distance(@error.association_name.to_s, n)
    }.reverse.first(4)
  else
    []
  end
end