Class: RailsRoutesAnalyzer::RouteIssue::NoAction

Inherits:
Base
  • Object
show all
Defined in:
lib/rails_routes_analyzer/route_issue/no_action.rb

Instance Method Summary collapse

Methods inherited from Base

#append_verbose_message, fields, #format_actions, #human_readable_error, #initialize, #suggestion, #verbose_message

Constructor Details

This class inherits a constructor from RailsRoutesAnalyzer::RouteIssue::Base

Instance Method Details

#error_suggestion(has_present_actions:, num_controllers:) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/rails_routes_analyzer/route_issue/no_action.rb', line 20

def error_suggestion(has_present_actions:, num_controllers:)
  actions = format_actions(missing_actions)
  if has_present_actions
    "remove case#{'s' if missing_actions.size > 1} for #{actions}"
  else
    "delete line, #{actions} matches nothing"
  end.tap do |message|
    message << " for controller #{controller_class_name}" if num_controllers > 1
  end
end

#human_readable_error_messageObject



10
11
12
13
14
15
16
17
18
# File 'lib/rails_routes_analyzer/route_issue/no_action.rb', line 10

def human_readable_error_message
  messages = missing_actions.map do |action|
    "`#{route_creation_method} :#{action}' call at #{file_location} there is no matching action in #{controller_class_name}"
  end

  return if messages.empty?

  messages.size == 1 ? messages[0] : messages
end

#try_to_fix_line(_line) ⇒ Object



31
32
33
# File 'lib/rails_routes_analyzer/route_issue/no_action.rb', line 31

def try_to_fix_line(_line)
  '' # Delete
end