Permalink
Browse files

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

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
1 parent 6d29f97 commit 5b89fd07b28bcd342f874ab08a03efd864db1340 @spastorino spastorino committed with josevalim Apr 11, 2010
Showing with 10 additions and 2 deletions.
  1. +8 −0 actionpack/lib/action_dispatch/routing/mapper.rb
  2. +2 −2 actionpack/test/dispatch/routing_test.rb
@@ -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

0 comments on commit 5b89fd0

Please sign in to comment.