aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing/mapper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_dispatch/routing/mapper.rb')
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb15
1 files changed, 7 insertions, 8 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 40e30bca6f..3eadb0e9fe 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -35,18 +35,17 @@ module ActionDispatch
end
def root(options = {})
- raise "Can't rename root to #{options[:as].inspect}: root is always named 'root'" if options.include?(:as)
- match '/', options.merge(:as => :root)
+ match '/', options.reverse_merge(:as => :root)
end
def match(*args)
- if args.one? && args.first.is_a?(Hash)
- options = args.first
- path = options.keys.first
- options[:to] = options.delete(path)
+ options = args.extract_options!
+
+ if args.empty?
+ path, to = options.find {|name,value| name.is_a?(String)}
+ options.merge!(:to => to).delete(path) if path
else
- path = args.first
- options = args.extract_options!
+ path = args.first
end
conditions, defaults = {}, {}