Changeset 8738
- Timestamp:
- 01/26/08 08:41:19 (4 months ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/routing.rb (modified) (1 diff)
- trunk/actionpack/lib/action_controller/routing/route_set.rb (modified) (1 diff)
- trunk/actionpack/test/controller/routing_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r8717 r8738 1 1 *SVN* 2 3 * Make map.root accept a single symbol as an argument to declare an alias. #10818 [bscofield] 4 5 e.g. map.dashboard '/dashboard', :controller=>'dashboard' 6 map.root :dashboard 2 7 3 8 * Handle corner case with image_tag when passed 'messed up' image names. #9018 [duncanbeevers, mpalmer] trunk/actionpack/lib/action_controller/routing.rb
r8674 r8738 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. trunk/actionpack/lib/action_controller/routing/route_set.rb
r8674 r8738 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 trunk/actionpack/test/controller/routing_test.rb
r8673 r8738 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)