Permalink
Browse files

Merge pull request #9441 from rubys/master

This is a small thing, motivated by #9419
  • Loading branch information...
guilleiguaran committed Feb 26, 2013
2 parents 8bc5e71 + 977455c commit b1dee8c2535b2bca6ebe69d18c24d29f9ba19470
Showing with 9 additions and 2 deletions.
  1. +9 −2 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -329,7 +329,6 @@ module Base
# 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 @@ def add_route(action, options) # :nodoc:
@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

0 comments on commit b1dee8c

Please sign in to comment.