Method: Innate::Node#action_missing

Defined in:
lib/innate/node.rb

#action_missing(path) ⇒ Object

The default handler in case no action was found, kind of method_missing. Must modify the response in order to have any lasting effect.

Reasoning:

  • We are doing this is in order to avoid tons of special error handling code that would impact runtime and make the overall API more complicated.

  • This cannot be a normal action is that methods defined in Innate::Node will never be considered for actions.

To use a normal action with template do following:

Examples:


class Hi
  include Innate::Node
  map '/'

  def self.action_missing(path)
    return if path == '/not_found'
    # No normal action, runs on bare metal
    try_resolve('/not_found')
  end

  def not_found
    # Normal action
    "Sorry, I do not exist"
  end
end

Parameters:

See Also:

API:

  • external



351
352
353
354
355
356
357
358
# File 'lib/innate/node.rb', line 351

def action_missing(path)
  response = Current.response
  response.status = 404
  response['Content-Type'] = 'text/plain'
  response.write("No action found at: %p" % path)

  response
end