aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing/route_set.rb
diff options
context:
space:
mode:
authorVijay Dev <vijaydev.cse@gmail.com>2013-03-30 15:47:38 +0530
committerVijay Dev <vijaydev.cse@gmail.com>2013-03-30 15:47:38 +0530
commite63086c135bf17a43e0807ecdef3e54b22048152 (patch)
tree89f51923c9ea02d49f4ea97e8ec3dc0f5e3c5119 /actionpack/lib/action_dispatch/routing/route_set.rb
parent06e22c01e86e47ebe0835e4c6ec351175cf91b96 (diff)
parent6d8c070821bc846eb263b8c045ae652ebd751569 (diff)
downloadrails-e63086c135bf17a43e0807ecdef3e54b22048152.tar.gz
rails-e63086c135bf17a43e0807ecdef3e54b22048152.tar.bz2
rails-e63086c135bf17a43e0807ecdef3e54b22048152.zip
Merge branch 'master' of github.com:rails/rails
Diffstat (limited to 'actionpack/lib/action_dispatch/routing/route_set.rb')
-rw-r--r--actionpack/lib/action_dispatch/routing/route_set.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index 619dd22ec1..7fb4719fa0 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -403,11 +403,19 @@ module ActionDispatch
def add_route(app, conditions = {}, requirements = {}, defaults = {}, name = nil, anchor = true)
raise ArgumentError, "Invalid route name: '#{name}'" unless name.blank? || name.to_s.match(/^[_a-z]\w*$/i)
+ if name && named_routes[name]
+ raise ArgumentError, "Invalid route name, already in use: '#{name}' \n" \
+ "You may have defined two routes with the same name using the `:as` option, or "
+ "you may be overriding a route already defined by a resource with the same naming. " \
+ "For the latter, you can restrict the routes created with `resources` as explained here: \n" \
+ "http://guides.rubyonrails.org/routing.html#restricting-the-routes-created"
+ end
+
path = build_path(conditions.delete(:path_info), requirements, SEPARATORS, anchor)
conditions = build_conditions(conditions, path.names.map { |x| x.to_sym })
route = @set.add_route(app, path, conditions, defaults, name)
- named_routes[name] = route if name && !named_routes[name]
+ named_routes[name] = route if name
route
end