Make namespace work with options[:to] [#4351 state:committed]

Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
Santiago Pastorino 2010-04-11 04:39:25 -03:00 committed by José Valim
parent 6d29f9789e
commit 5b89fd07b2
2 changed files with 10 additions and 2 deletions

@ -55,6 +55,14 @@ def extract_path_and_options(args)
path = args.first
end
if @scope[:module] && options[:to]
if options[:to].to_s.include?("#")
options[:to] = "#{@scope[:module]}/#{options[:to]}"
elsif @scope[:controller].nil?
options[:to] = "#{@scope[:module]}##{options[:to]}"
end
end
path = normalize_path(path)
if using_match_shorthand?(path, options)

@ -140,7 +140,7 @@ def self.matches?(request)
namespace :account do
match 'shorthand'
match 'description', :to => "account#description", :as => "description"
match 'description', :to => "description", :as => "description"
resource :subscription, :credit, :credit_card
root :to => "account#index"
@ -864,7 +864,7 @@ def test_namespaced_roots
with_test_routes do
assert_equal '/account', account_root_path
get '/account'
assert_equal 'account#index', @response.body
assert_equal 'account/account#index', @response.body
end
end