Class: ActionController::ParameterMissing::Correction

Inherits:
Object
  • Object
show all
Defined in:
lib/action_controller/metal/strong_parameters.rb

Instance Method Summary collapse

Constructor Details

#initialize(error) ⇒ Correction

Returns a new instance of Correction.



31
32
33
# File 'lib/action_controller/metal/strong_parameters.rb', line 31

def initialize(error)
  @error = error
end

Instance Method Details

#correctionsObject



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/action_controller/metal/strong_parameters.rb', line 35

def corrections
  if @error.param && @error.keys
    maybe_these = @error.keys

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