aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller
diff options
context:
space:
mode:
authorNicholas Seckar <nseckar@gmail.com>2005-07-14 10:32:37 +0000
committerNicholas Seckar <nseckar@gmail.com>2005-07-14 10:32:37 +0000
commitbf0b7588ee4e32353e0dc10c2d1c3d2b9ea952c4 (patch)
treefd60c9c5a207eb5012679ca23b4d2a33a15102ae /actionpack/lib/action_controller
parent6ed16ff60290620c87772670d312585f2431d03f (diff)
downloadrails-bf0b7588ee4e32353e0dc10c2d1c3d2b9ea952c4.tar.gz
rails-bf0b7588ee4e32353e0dc10c2d1c3d2b9ea952c4.tar.bz2
rails-bf0b7588ee4e32353e0dc10c2d1c3d2b9ea952c4.zip
Add RouteSet#named_route so that RouteSet instance methods do not shadow available route names
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1834 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r--actionpack/lib/action_controller/routing.rb16
1 files changed, 12 insertions, 4 deletions
diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb
index fd9904a20e..82b12f3a7b 100644
--- a/actionpack/lib/action_controller/routing.rb
+++ b/actionpack/lib/action_controller/routing.rb
@@ -573,13 +573,21 @@ module ActionController
def each(&block) @routes.each(&block) end
- def method_missing(name, *args)
- return super(name, *args) unless (1..2).include?(args.length)
-
- route = connect(*args)
+ # Defines a new named route with the provided name and arguments.
+ # This method need only be used when you wish to use a name that a RouteSet instance
+ # method exists for, such as categories.
+ #
+ # For example, map.categories '/categories', :controller => 'categories' will not work
+ # due to RouteSet#categories.
+ def named_route(name, path, hash = {})
+ route = connect(path, hash)
NamedRoutes.name_route(route, name)
route
end
+
+ def method_missing(name, *args)
+ (1..2).include?(args.length) ? named_route(name, *args) : super(name, *args)
+ end
def extra_keys(options, recall = {})
generate(options.dup, recall).last.keys