Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 5671

Show
Ignore:
Timestamp:
12/04/06 00:12:00 (2 years ago)
Author:
david
Message:

Dropped the idea of automatically routing :format for the vanilla routes -- 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)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1-2-pre-release/actionpack/lib/action_controller/routing.rb

    r5608 r5671  
    979979          @set.add_named_route(name, path, options) 
    980980        end 
     981 
     982        # Added deprecation notice for anyone who already added a named route called "root". 
     983        # It'll be used as a shortcut for map.connect '' in Rails 2.0. 
     984        def root(*args, &proc) 
     985          super unless args.length >= 1 && proc.nil? 
     986          @set.add_named_route("root", *args) 
     987        end 
     988        deprecate :root => "(as the the label for a named route) will become a shortcut for map.connect '', so find another name" 
    981989 
    982990        def method_missing(route_name, *args, &proc) 
  • branches/1-2-pre-release/actionpack/test/controller/routing_test.rb

    r5608 r5671  
    377377  def test_named_url_with_no_action_specified 
    378378    rs.draw do |map| 
    379       map.root '', :controller => 'content' 
     379      map.home '', :controller => 'content' 
    380380      map.connect ':controller/:action/:id' 
    381381    end 
     
    385385     
    386386    x = setup_for_named_route.new 
    387     assert_equal({:controller => 'content', :action => 'index', :use_route => :root, :only_path => false}, 
    388                  x.send(:root_url)) 
     387    assert_equal({:controller => 'content', :action => 'index', :use_route => :home, :only_path => false}, 
     388                 x.send(:home_url)) 
    389389  end 
    390390   
     
    392392    [{:controller => 'content', :action => 'index'}, {:controller => 'content'}].each do |hash|  
    393393      rs.draw do |map| 
    394         map.root '', hash 
     394        map.home '', hash 
    395395        map.connect ':controller/:action/:id' 
    396396      end 
     
    15831583  end 
    15841584 
     1585  def test_deprecation_warning_for_root_route 
     1586    Object.const_set(:PeopleController, Class.new) 
     1587 
     1588    set.draw do |map| 
     1589      assert_deprecated do 
     1590        map.root('', :controller => "people") 
     1591      end     
     1592    end 
     1593  ensure 
     1594    Object.send(:remove_const, :PeopleController) 
     1595  end 
     1596 
    15851597  def test_generate_with_default_action 
    15861598    set.draw do |map| 
  • branches/1-2-pre-release/railties/CHANGELOG

    r5652 r5671  
    11*SVN* 
     2 
     3* Deprecated the name route "root" as it'll be used as a shortcut for map.connect '' in Rails 2.0 [DHH] 
    24 
    35* Fixed that script/server running against Mongrel should tail the proper log regardless of the environment [DHH] 
  • trunk/actionpack/CHANGELOG

    r5664 r5671  
    11*SVN* 
     2 
     3* Added map.root as an alias for map.connect '' [DHH] 
    24 
    35* Added Request#format to return the format used for the request as a mime type. If no format is specified, the first Request#accepts type is used. This means you can stop using respond_to for anything else than responses [DHH]. Examples: 
  • trunk/actionpack/lib/action_controller/routing.rb

    r5607 r5671  
    974974        def connect(path, options = {}) 
    975975          @set.add_route(path, options) 
     976        end 
     977 
     978        # Creates a named route called "root" for matching the root level request. 
     979        def root(options = {}) 
     980          named_route("root", '', options) 
    976981        end 
    977982 
  • trunk/actionpack/test/controller/routing_test.rb

    r5607 r5671  
    377377  def test_named_url_with_no_action_specified 
    378378    rs.draw do |map| 
    379       map.root '', :controller => 'content' 
     379      map.home '', :controller => 'content' 
    380380      map.connect ':controller/:action/:id' 
    381381    end 
     
    385385     
    386386    x = setup_for_named_route.new 
    387     assert_equal({:controller => 'content', :action => 'index', :use_route => :root, :only_path => false}, 
    388                  x.send(:root_url)) 
     387    assert_equal({:controller => 'content', :action => 'index', :use_route => :home, :only_path => false}, 
     388                 x.send(:home_url)) 
    389389  end 
    390390   
     
    392392    [{:controller => 'content', :action => 'index'}, {:controller => 'content'}].each do |hash|  
    393393      rs.draw do |map| 
    394         map.root '', hash 
     394        map.home '', hash 
    395395        map.connect ':controller/:action/:id' 
    396396      end 
     
    15931593  end 
    15941594 
     1595  def test_root_map 
     1596    Object.const_set(:PeopleController, Class.new) 
     1597 
     1598    set.draw { |map| map.root :controller => "people" } 
     1599 
     1600    request.path = "" 
     1601    request.method = :get 
     1602    assert_nothing_raised { set.recognize(request) } 
     1603    assert_equal("people", request.path_parameters[:controller]) 
     1604    assert_equal("index", request.path_parameters[:action]) 
     1605  ensure 
     1606    Object.send(:remove_const, :PeopleController) 
     1607  end 
     1608 
    15951609  def test_generate_finds_best_fit 
    15961610    set.draw do |map| 
  • trunk/railties/configs/routes.rb

    r5148 r5671  
    99  # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase' 
    1010  # This route can be invoked with purchase_url(:id => product.id) 
     11   
     12  # Sample resource route (maps HTTP verbs to controller actions automatically): 
     13  # map.resources :products 
    1114 
    12   # You can have the root of your site routed by hooking up ''  
     15  # Sample resource route with options: 
     16  # map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get } 
     17 
     18  # You can have the root of your site routed with map.root 
    1319  # -- just remember to delete public/index.html. 
    14   # map.connect '', :controller => "welcome" 
     20  # map.root :controller => "welcome" 
    1521 
    16   # Allow downloading Web Service WSDL as a file with an extension 
    17   # instead of a file named 'wsdl' 
     22  # Allow downloading Web Service WSDL as a file with an extension instead of a file named 'wsdl' 
    1823  map.connect ':controller/service.wsdl', :action => 'wsdl' 
    1924 
    2025  # Install the default route as the lowest priority. 
    21   map.connect ':controller/:action/:id.:format' 
    2226  map.connect ':controller/:action/:id' 
    2327end