diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-02-15 00:51:02 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-02-15 00:51:02 +0000 |
commit | c844755e5a0c3d4edfcc78f9c30ef91fa0de550a (patch) | |
tree | 4cf4890fc5af5f58dd0a6a19c0a6fea6ed39a1df /actionpack/lib/action_controller/base.rb | |
parent | a3298e5efdf33398b49933323ea3fef7ff4e9a9c (diff) | |
download | rails-c844755e5a0c3d4edfcc78f9c30ef91fa0de550a.tar.gz rails-c844755e5a0c3d4edfcc78f9c30ef91fa0de550a.tar.bz2 rails-c844755e5a0c3d4edfcc78f9c30ef91fa0de550a.zip |
Merged back the Routing branch
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@614 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/base.rb')
-rwxr-xr-x | actionpack/lib/action_controller/base.rb | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index cfcd46d985..a30f3b94d7 100755 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -13,6 +13,13 @@ module ActionController #:nodoc: end class MissingTemplate < ActionControllerError #:nodoc: end + class RoutingError < ActionControllerError + attr_reader :failures + def initialize(message, failures=[]) + super(message) + @failures = failures + end + end class UnknownAction < ActionControllerError #:nodoc: end class MissingFile < ActionControllerError #:nodoc: @@ -205,6 +212,12 @@ module ActionController #:nodoc: # should instead be implemented in the controller to determine when debugging screens should be shown. @@consider_all_requests_local = true cattr_accessor :consider_all_requests_local + + # Enable or disable the collection of failure information for RoutingErrors. + # This information can be extremely useful when tweaking custom routes, but is + # pointless once routes have been tested and verified. + @@debug_routes = true + cattr_accessor :debug_routes # Template root determines the base from which template references will be made. So a call to render("test/template") # will be converted to "#{template_root}/test/template.rhtml". @@ -261,6 +274,14 @@ module ActionController #:nodoc: def controller_name Inflector.underscore(controller_class_name.sub(/Controller/, "")) end + + # Convert the class name from something like "OneModule::TwoModule::NeatController" to "one_module/two_module/neat". + def controller_path + components = self.name.to_s.split('::').collect { |name| name.underscore } + components[-1] = $1 if /^(.*)_controller$/ =~ components[-1] + components.shift if components.first == 'controllers' # Transitional conditional to accomodate root Controllers module + components.join('/') + end end public @@ -337,10 +358,6 @@ module ActionController #:nodoc: end end - def module_name - @params["module"] - end - # Converts the class name from something like "OneModule::TwoModule::NeatController" to "NeatController". def controller_class_name self.class.controller_class_name @@ -691,7 +708,7 @@ module ActionController #:nodoc: end def default_template_name(default_action_name = action_name) - module_name ? "#{module_name}/#{controller_name}/#{default_action_name}" : "#{controller_name}/#{default_action_name}" + "#{self.class.controller_path}/#{default_action_name}" end end end |