Class: ActionController::UrlGenerationError::Correction
- Inherits:
-
Object
- Object
- ActionController::UrlGenerationError::Correction
- Defined in:
- lib/action_controller/metal/exceptions.rb
Instance Method Summary collapse
- #corrections ⇒ Object
-
#initialize(error) ⇒ Correction
constructor
A new instance of Correction.
Constructor Details
#initialize(error) ⇒ Correction
Returns a new instance of Correction.
37 38 39 |
# File 'lib/action_controller/metal/exceptions.rb', line 37 def initialize(error) @error = error end |
Instance Method Details
#corrections ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/action_controller/metal/exceptions.rb', line 41 def corrections if @error.method_name maybe_these = @error.routes.named_routes.helper_names.grep(/#{@error.route_name}/) maybe_these -= [@error.method_name.to_s] # remove exact match maybe_these.sort_by { |n| DidYouMean::Jaro.distance(@error.route_name, n) }.reverse.first(4) else [] end end |