class method
self.controller_name
Ruby on Rails 7.1.6
Since v3.0.20Signature
self.controller_name()
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
Source
# File actionpack/lib/action_controller/metal.rb, line 130
def self.controller_name
@controller_name ||= (name.demodulize.delete_suffix("Controller").underscore unless anonymous?)
end
Defined in actionpack/lib/action_controller/metal.rb line 130
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionController::Metal