aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillermo Iguaran <guilleiguaran@gmail.com>2013-02-26 06:56:06 -0800
committerGuillermo Iguaran <guilleiguaran@gmail.com>2013-02-26 06:56:06 -0800
commitb1dee8c2535b2bca6ebe69d18c24d29f9ba19470 (patch)
tree249a0fc7fed5fafed2ef75a1596d3fc0ee987fc0
parent8bc5e714f48af5ef94e4c884121ca55729013c7b (diff)
parent977455cc2efb94f40b4c0d46d1842be198ed7c4c (diff)
downloadrails-b1dee8c2535b2bca6ebe69d18c24d29f9ba19470.tar.gz
rails-b1dee8c2535b2bca6ebe69d18c24d29f9ba19470.tar.bz2
rails-b1dee8c2535b2bca6ebe69d18c24d29f9ba19470.zip
Merge pull request #9441 from rubys/master
This is a small thing, motivated by https://github.com/rails/rails/issues/9419
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index a8e225d61c..817480c7ae 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -329,7 +329,6 @@ module ActionDispatch
# because this means it will be matched first. As this is the most popular route
# of most Rails applications, this is beneficial.
def root(options = {})
- options = { :to => options } if options.is_a?(String)
match '/', { :as => :root, :via => :get }.merge!(options)
end
@@ -1427,7 +1426,15 @@ module ActionDispatch
@set.add_route(app, conditions, requirements, defaults, as, anchor)
end
- def root(options={})
+ def root(path, options={})
+ if path.is_a?(String)
+ options[:to] = path
+ elsif path.is_a?(Hash) and options.empty?
+ options = path
+ else
+ raise ArgumentError, "must be called with a path and/or options"
+ end
+
if @scope[:scope_level] == :resources
with_scope_level(:root) do
scope(parent_resource.path) do