123456789_123456789_123456789_123456789_123456789_

Class: ActiveRecord::AssociationNotFoundError::Correction

Relationships & Source Files
Inherits: Object
Defined in: activerecord/lib/active_record/associations.rb

Class Method Summary

Instance Method Summary

Constructor Details

.new(error) ⇒ Correction

[ GitHub ]

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

def initialize(error)
  @error = error
end

Instance Method Details

#corrections

[ GitHub ]

  
# File 'activerecord/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