Ticket #10818: simplified_route_aliasing.patch
| File simplified_route_aliasing.patch, 2.7 kB (added by bscofield, 8 months ago) |
|---|
-
a/actionpack/lib/action_controller/routing.rb
old new 115 115 # root_url # => 'http://www.example.com/' 116 116 # root_path # => '' 117 117 # 118 # You can also specify an already-defined named route in your map.root call: 119 # 120 # # In routes.rb 121 # map.new_session :controller => 'sessions', :action => 'new' 122 # map.root :new_session 123 # 118 124 # Note: when using +with_options+, the route is simply named after the 119 125 # method you call on the block parameter rather than map. 120 126 # -
a/actionpack/lib/action_controller/routing/route_set.rb
old new 19 19 20 20 # Creates a named route called "root" for matching the root level request. 21 21 def root(options = {}) 22 if options.is_a?(Symbol) 23 if source_route = @set.named_routes.routes[options] 24 options = source_route.defaults.merge({ :conditions => source_route.conditions }) 25 end 26 end 22 27 named_route("root", '', options) 23 28 end 24 29 -
a/actionpack/test/controller/routing_test.rb
old new 1808 1808 Object.send(:remove_const, :PeopleController) 1809 1809 end 1810 1810 1811 def test_recognize_with_alias_in_conditions 1812 Object.const_set(:PeopleController, Class.new) 1813 1814 set.draw do |map| 1815 map.people "/people", :controller => 'people', :action => "index", 1816 :conditions => { :method => :get } 1817 map.root :people 1818 end 1819 1820 request.path = "/people" 1821 request.method = :get 1822 assert_nothing_raised { set.recognize(request) } 1823 assert_equal("people", request.path_parameters[:controller]) 1824 assert_equal("index", request.path_parameters[:action]) 1825 1826 request.path = "/" 1827 request.method = :get 1828 assert_nothing_raised { set.recognize(request) } 1829 assert_equal("people", request.path_parameters[:controller]) 1830 assert_equal("index", request.path_parameters[:action]) 1831 ensure 1832 Object.send(:remove_const, :PeopleController) 1833 end 1834 1811 1835 def test_typo_recognition 1812 1836 Object.const_set(:ArticlesController, Class.new) 1813 1837