diff options
author | José Valim <jose.valim@gmail.com> | 2009-12-31 01:33:54 +0100 |
---|---|---|
committer | Yehuda Katz <wycats@Yehuda-Katz.local> | 2009-12-31 18:40:20 -0800 |
commit | 38fa0d14a8c96fc6e02531408be5ce8c36f4fb7a (patch) | |
tree | af5d5ab4f6fb1393d4c86082c280fe8d9cfe1e37 /actionpack/lib/abstract_controller/base.rb | |
parent | db49b7dc94a744fd53eaf80107995ca55f9415e8 (diff) | |
download | rails-38fa0d14a8c96fc6e02531408be5ce8c36f4fb7a.tar.gz rails-38fa0d14a8c96fc6e02531408be5ce8c36f4fb7a.tar.bz2 rails-38fa0d14a8c96fc6e02531408be5ce8c36f4fb7a.zip |
controller_path is required by ActionView, so move it up to AbstractController and refactor AbstractController::Layouts.
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 |