Class: Hanami::Routes::MissingActionError

Inherits:
Error
  • Object
show all
Defined in:
lib/hanami/routes.rb

Overview

Error raised when no action could be found in an app or slice container for the key given in a routes file.

Since:

  • 2.0.0

Instance Method Summary collapse

Constructor Details

#initialize(action_key, slice) ⇒ MissingActionError

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of MissingActionError.

Since:

  • 2.0.0



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/hanami/routes.rb', line 36

def initialize(action_key, slice)
  action_path = action_key.gsub(CONTAINER_KEY_DELIMITER, PATH_DELIMITER)
  action_constant = slice.inflector.camelize(
    "#{slice.inflector.underscore(slice.namespace.to_s)}#{PATH_DELIMITER}#{action_path}"
  )
  action_file = slice.root.join("#{action_path}#{RB_EXT}")

  super(<<~MSG)
    Could not find action with key #{action_key.inspect} in #{slice}

    To fix this, define the action class #{action_constant} in #{action_file}
  MSG
end