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

Changeset 6125

Show
Ignore:
Timestamp:
02/04/07 22:27:45 (2 years ago)
Author:
rick
Message:

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
superclass' view_paths. [Rick]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r6120 r6125  
    11*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 
     4superclass' view_paths.  [Rick] 
    25 
    36* 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  
    357357      # Deprecated. Use view_paths instead. 
    358358      def template_root=(path) 
    359         view_paths.unshift(path) 
    360       end 
    361       deprecate :template_root= => :view_paths 
     359        prepend_view_path path 
     360        template_root 
     361      end 
    362362       
    363363      # Deprecated. Use view_paths instead. 
     
    375375        @@view_paths[name] = value 
    376376      end 
    377        
     377 
    378378      # View load paths for controller. 
    379379      def view_paths 
     
    387387          end 
    388388        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 
    389405      end 
    390406       
  • trunk/actionpack/lib/action_controller/components.rb

    r5631 r6125  
    7878        path_of_calling_controller = File.dirname(caller[1].split(/:\d+:/, 2).first) 
    7979        path_of_controller_root    = path_of_calling_controller.sub(/#{Regexp.escape(File.dirname(controller_path))}$/, "") 
    80  
    81         self.template_root = path_of_controller_roo
     80        prepend_view_path path_of_controller_root 
     81        view_paths.firs
    8282      end 
    8383 
  • trunk/actionpack/test/controller/view_paths_test.rb

    r6120 r6125  
    4747  def test_template_root_deprecated 
    4848    assert_deprecated(/template_root.*view_paths/) do 
    49       TestController.template_root = LOAD_PATH_ROOT 
     49      TestController.template_root = 'foo/bar' 
    5050    end 
    5151    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 
    5354    end 
    5455  end 
  • trunk/actionwebservice/test/scaffolded_controller_test.rb

    r5378 r6125  
    66end 
    77 
    8 ActionController::Base.template_root = '.' 
     8ActionController::Base.view_load_paths = [ '.' ] 
    99 
    1010class ScaffoldPerson < ActionWebService::Struct