Method: ActionController::Metal.controller_name

Defined in:
actionpack/lib/action_controller/metal.rb

.controller_nameObject

Returns the last part of the controller’s name, underscored, without the ending ‘Controller`. For instance, `PostsController` returns `posts`. Namespaces are left out, so `Admin::PostsController` returns `posts` as well.

#### Returns

  • ‘string`



130
131
132
# File 'actionpack/lib/action_controller/metal.rb', line 130

def self.controller_name
  @controller_name ||= (name.demodulize.delete_suffix("Controller").underscore unless anonymous?)
end