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



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

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_path = slice.relative_source_path.join(action_path).to_s.concat(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_path}
  MSG
end