123456789_123456789_123456789_123456789_123456789_

Class: ActionController::ParameterMissing::Correction

Relationships & Source Files
Inherits: Object
Defined in: actionpack/lib/action_controller/metal/strong_parameters.rb

Class Method Summary

Instance Method Summary

Constructor Details

.new(error) ⇒ Correction

[ GitHub ]

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

def initialize(error)
  @error = error
end

Instance Method Details

#corrections

[ GitHub ]

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