aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2010-04-09 23:09:15 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2010-04-09 23:09:15 -0700
commit7353fc15957aa3b32eae8cf495701a7163cf8dbc (patch)
tree5e312a5f685b5ad5628e84ddf137a6a3af7cacb7 /actionpack
parent561d9eff0c5702c449a2a0117ad9950ad8842dc2 (diff)
downloadrails-7353fc15957aa3b32eae8cf495701a7163cf8dbc.tar.gz
rails-7353fc15957aa3b32eae8cf495701a7163cf8dbc.tar.bz2
rails-7353fc15957aa3b32eae8cf495701a7163cf8dbc.zip
Dial back from 'namespace :controller => ...' to 'scope :module => ...'
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG18
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb22
-rw-r--r--actionpack/test/dispatch/routing_test.rb8
3 files changed, 13 insertions, 35 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 9b18e43516..21c6eb8c87 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,20 +1,10 @@
*Rails 3.0.0 [beta 3] (pending)*
-* Routes can be selectively namespaced by path or controller module. [Jeremy Kemper]
+* Routes can be scoped by controller module. [Jeremy Kemper]
- # /users => Admin::UsersController
- namespace :controller => 'admin' do
- resources :users
- end
-
- # /admin/users => UsersController
- namespace :path => 'admin' do
- resources :users
- end
-
- # /admin/users => Admin::UsersController
- namespace :admin do
- resources :users
+ # /session => Auth::SessionsController
+ scope :module => 'auth' do
+ resource :session
end
* Added #favicon_link_tag, it uses #image_path so in particular the favicon gets an asset ID [fxn]
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index bf707f354a..61256e8df1 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -323,21 +323,9 @@ module ActionDispatch
scope(controller.to_sym) { yield }
end
- def namespace(path_or_options)
- options =
- case path_or_options
- when String, Symbol
- path = path_or_options.to_s
- { :path => path,
- :name_prefix => path,
- :controller_namespace => path }
- when Hash
- { :path => path_or_options[:path],
- :controller_namespace => path_or_options[:controller] }
- else
- raise ArgumentError, "Unknown namespace: #{path_or_options.inspect}"
- end
- scope(options) { yield }
+ def namespace(path)
+ path = path.to_s
+ scope(:path => path, :name_prefix => path, :module => path) { yield }
end
def constraints(constraints = {})
@@ -376,12 +364,12 @@ module ActionDispatch
parent ? "#{parent}_#{child}" : child
end
- def merge_controller_namespace_scope(parent, child)
+ def merge_module_scope(parent, child)
parent ? "#{parent}/#{child}" : child
end
def merge_controller_scope(parent, child)
- @scope[:controller_namespace] ? "#{@scope[:controller_namespace]}/#{child}" : child
+ @scope[:module] ? "#{@scope[:module]}/#{child}" : child
end
def merge_resources_path_names_scope(parent, child)
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index 38341b5d8c..d38c48bfd4 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -187,11 +187,11 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
resource :dashboard, :constraints => { :ip => /192\.168\.1\.\d{1,3}/ }
- namespace :controller => :api do
+ scope :module => 'api' do
resource :token
end
- namespace :path => :api do
+ scope :path => 'api' do
resource :me
match '/' => 'mes#index'
end
@@ -951,7 +951,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
end
- def test_controller_namespace
+ def test_module_scope
with_test_routes do
get '/token'
assert_equal 'api/tokens#show', @response.body
@@ -959,7 +959,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
end
- def test_path_namespace
+ def test_path_scope
with_test_routes do
get '/api/me'
assert_equal 'mes#show', @response.body