Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Dropped the idea of automatically routing :format for the vanilla rou…

…tes -- that will be a treat for map.resources. Deprecated the name route root as it'll be used as a shortcut for map.connect '' in Rails 2.0 (Rails 1.2). Added map.root as an alias for map.connect '' (Rails 2.0)

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-pre-release@5671 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit ffb17e89efb036081f71097d4d885d3d8efe6d5b 1 parent 2a08c45
@dhh dhh authored
View
8 actionpack/lib/action_controller/routing.rb
@@ -979,6 +979,14 @@ def named_route(name, path, options = {})
@set.add_named_route(name, path, options)
end
+ # Added deprecation notice for anyone who already added a named route called "root".
+ # It'll be used as a shortcut for map.connect '' in Rails 2.0.
+ def root(*args, &proc)
+ super unless args.length >= 1 && proc.nil?
+ @set.add_named_route("root", *args)
+ end
+ deprecate :root => "(as the the label for a named route) will become a shortcut for map.connect '', so find another name"
+
def method_missing(route_name, *args, &proc)
super unless args.length >= 1 && proc.nil?
@set.add_named_route(route_name, *args)
View
20 actionpack/test/controller/routing_test.rb
@@ -376,7 +376,7 @@ def test_url_with_no_action_specified
def test_named_url_with_no_action_specified
rs.draw do |map|
- map.root '', :controller => 'content'
+ map.home '', :controller => 'content'
map.connect ':controller/:action/:id'
end
@@ -384,14 +384,14 @@ def test_named_url_with_no_action_specified
assert_equal '/', rs.generate(:controller => 'content')
x = setup_for_named_route.new
- assert_equal({:controller => 'content', :action => 'index', :use_route => :root, :only_path => false},
- x.send(:root_url))
+ assert_equal({:controller => 'content', :action => 'index', :use_route => :home, :only_path => false},
+ x.send(:home_url))
end
def test_url_generated_when_forgetting_action
[{:controller => 'content', :action => 'index'}, {:controller => 'content'}].each do |hash|
rs.draw do |map|
- map.root '', hash
+ map.home '', hash
map.connect ':controller/:action/:id'
end
assert_equal '/', rs.generate({:action => nil}, {:controller => 'content', :action => 'hello'})
@@ -1582,6 +1582,18 @@ def test_recognize_with_conditions_and_format
Object.send(:remove_const, :PeopleController)
end
+ def test_deprecation_warning_for_root_route
+ Object.const_set(:PeopleController, Class.new)
+
+ set.draw do |map|
+ assert_deprecated do
+ map.root('', :controller => "people")
+ end
+ end
+ ensure
+ Object.send(:remove_const, :PeopleController)
+ end
+
def test_generate_with_default_action
set.draw do |map|
map.connect "/people", :controller => "people"
View
2  railties/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Deprecated the name route "root" as it'll be used as a shortcut for map.connect '' in Rails 2.0 [DHH]
+
* Fixed that script/server running against Mongrel should tail the proper log regardless of the environment [DHH]
* Update initializer to load Rails::VERSION as soon as possible. Closes #6698. [Nicholas Seckar]
Please sign in to comment.
Something went wrong with that request. Please try again.