diff options
Diffstat (limited to 'actionpack/lib/abstract_controller/base.rb')
-rw-r--r-- | actionpack/lib/abstract_controller/base.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/actionpack/lib/abstract_controller/base.rb b/actionpack/lib/abstract_controller/base.rb index efea81aa71..a6889d5d01 100644 --- a/actionpack/lib/abstract_controller/base.rb +++ b/actionpack/lib/abstract_controller/base.rb @@ -72,6 +72,16 @@ module AbstractController # And always exclude explicitly hidden actions hidden_actions end + + # Returns the full controller name, underscored, without the ending Controller. + # For instance, MyApp::MyPostsController would return "my_app/my_posts" for + # controller_name. + # + # ==== Returns + # String + def controller_path + @controller_path ||= name && name.sub(/Controller$/, '').underscore + end end abstract! @@ -96,6 +106,11 @@ module AbstractController process_action(action_name, *args) end + # Delegates to the class' #controller_path + def controller_path + self.class.controller_path + end + private # Returns true if the name can be considered an action. This can # be overridden in subclasses to modify the semantics of what |