From 6ed16ff60290620c87772670d312585f2431d03f Mon Sep 17 00:00:00 2001 From: Nicholas Seckar Date: Thu, 14 Jul 2005 09:09:39 +0000 Subject: Provide correct defaults for Named Routes which do not specify :action git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1833 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_controller/routing.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'actionpack/lib/action_controller/routing.rb') diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb index f7d3fe3369..fd9904a20e 100644 --- a/actionpack/lib/action_controller/routing.rb +++ b/actionpack/lib/action_controller/routing.rb @@ -288,9 +288,16 @@ module ActionController generator.before, generator.current, generator.after = [], components.first, (components[1..-1] || []) if known.empty? then generator.go - else generator.if(generator.check_conditions(known)) {|gp| gp.go } + else + # Alter the conditions to allow :action => 'index' to also catch :action => nil + altered_known = known.collect do |k, v| + if k == :action && v== 'index' then [k, [nil, 'index']] + else [k, v] + end + end + generator.if(generator.check_conditions(altered_known)) {|gp| gp.go } end - + generator end @@ -363,7 +370,7 @@ module ActionController def add_default_requirements component_keys = components.collect {|c| c.key} - known[:action] ||= [nil, 'index'] unless component_keys.include? :action + known[:action] ||= 'index' unless component_keys.include? :action end end -- cgit v1.2.3