Changeset 6125
- Timestamp:
- 02/04/07 22:27:45 (2 years ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/base.rb (modified) (3 diffs)
- trunk/actionpack/lib/action_controller/components.rb (modified) (1 diff)
- trunk/actionpack/test/controller/view_paths_test.rb (modified) (1 diff)
- trunk/actionwebservice/test/scaffolded_controller_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r6120 r6125 1 1 *SVN* 2 3 * Fix issue with deprecation messing up #template_root= usage. Add #prepend_view_path and #append_view_path to allow modification of a copy of the 4 superclass' view_paths. [Rick] 2 5 3 6 * Allow Controllers to have multiple view_paths instead of a single template_root. Closes #2754 [John Long] trunk/actionpack/lib/action_controller/base.rb
r6120 r6125 357 357 # Deprecated. Use view_paths instead. 358 358 def template_root=(path) 359 view_paths.unshift(path)360 end361 deprecate :template_root= => :view_paths359 prepend_view_path path 360 template_root 361 end 362 362 363 363 # Deprecated. Use view_paths instead. … … 375 375 @@view_paths[name] = value 376 376 end 377 377 378 378 # View load paths for controller. 379 379 def view_paths … … 387 387 end 388 388 end 389 end 390 391 # Adds a view_path to the front of the view_paths array. 392 # If the current class has no view paths, copy them from 393 # the superclass 394 def prepend_view_path(path) 395 self.view_paths = view_paths.dup if view_paths.frozen? 396 view_paths.unshift(path) 397 end 398 399 # Adds a view_path to the end of the view_paths array. 400 # If the current class has no view paths, copy them from 401 # the superclass 402 def append_view_path(path) 403 self.view_paths = view_paths.dup if view_paths.frozen? 404 view_paths << path 389 405 end 390 406 trunk/actionpack/lib/action_controller/components.rb
r5631 r6125 78 78 path_of_calling_controller = File.dirname(caller[1].split(/:\d+:/, 2).first) 79 79 path_of_controller_root = path_of_calling_controller.sub(/#{Regexp.escape(File.dirname(controller_path))}$/, "") 80 81 self.template_root = path_of_controller_root80 prepend_view_path path_of_controller_root 81 view_paths.first 82 82 end 83 83 trunk/actionpack/test/controller/view_paths_test.rb
r6120 r6125 47 47 def test_template_root_deprecated 48 48 assert_deprecated(/template_root.*view_paths/) do 49 TestController.template_root = LOAD_PATH_ROOT49 TestController.template_root = 'foo/bar' 50 50 end 51 51 assert_deprecated(/template_root.*view_paths/) do 52 assert_equal LOAD_PATH_ROOT, TestController.template_root 52 assert_equal 'foo/bar', TestController.template_root 53 assert_equal ['foo/bar', LOAD_PATH_ROOT], TestController.view_paths 53 54 end 54 55 end trunk/actionwebservice/test/scaffolded_controller_test.rb
r5378 r6125 6 6 end 7 7 8 ActionController::Base. template_root = '.'8 ActionController::Base.view_load_paths = [ '.' ] 9 9 10 10 class ScaffoldPerson < ActionWebService::Struct