Changeset 4762
- Timestamp:
- 08/15/06 01:28:06 (2 years ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/routing.rb (modified) (5 diffs)
- trunk/actionpack/test/controller/routing_test.rb (modified) (2 diffs)
- trunk/railties/CHANGELOG (modified) (1 diff)
- trunk/railties/lib/initializer.rb (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r4757 r4762 1 1 *SVN* 2 2 3 * Add controller_paths variable to Routing. [Nicholas Seckar] 4 3 5 * Fix assert_redirected_to issue with named routes for module controllers. [Rick Olson] 4 6 5 7 * Tweak RoutingError message to show option diffs, not just missing named route significant keys. [Rick Olson] 6 8 9 >>>>>>> .r4761 7 10 * Invoke method_missing directly on hidden actions. Closes #3030. [Nicholas Seckar] 8 11 trunk/actionpack/lib/action_controller/routing.rb
r4756 r4762 50 50 module Routing 51 51 SEPARATORS = %w( / ; . , ? ) 52 53 # The root paths which may contain controller files 54 mattr_accessor :controller_paths 55 self.controller_paths = [] 52 56 53 57 class << self … … 59 63 end 60 64 61 def normalize_paths(paths = $LOAD_PATH)65 def normalize_paths(paths) 62 66 # do the hokey-pokey of path normalization... 63 67 paths = paths.collect do |path| … … 81 85 @possible_controllers = [] 82 86 83 paths = $LOAD_PATH.select { |path| File.directory?(path) && path != "." }87 paths = controller_paths.select { |path| File.directory?(path) && path != "." } 84 88 85 89 seen_paths = Hash.new {|h, k| h[k] = true; false} … … 87 91 Dir["#{load_path}/**/*_controller.rb"].collect do |path| 88 92 next if seen_paths[path.gsub(%r{^\.[/\\]}, "")] 89 93 90 94 controller_name = path[(load_path.length + 1)..-1] 91 next unless path_may_be_controller?(controller_name) 92 95 93 96 controller_name.gsub!(/_controller\.rb\Z/, '') 94 97 @possible_controllers << controller_name … … 100 103 end 101 104 @possible_controllers 102 end103 104 def path_may_be_controller?(path)105 path !~ /(?:rails\/.*\/(?:examples|test))|(?:actionpack\/lib\/action_controller.rb$)|(?:app\/controllers)/o106 105 end 107 106 trunk/actionpack/test/controller/routing_test.rb
r4757 r4762 1515 1515 1516 1516 def test_possible_controllers 1517 true_ load_paths = $LOAD_PATH.dup1517 true_controller_paths = ActionController::Routing.controller_paths 1518 1518 1519 1519 ActionController::Routing.use_controllers! nil 1520 1520 Object.send(:const_set, :RAILS_ROOT, File.dirname(__FILE__) + '/controller_fixtures') 1521 1521 1522 $LOAD_PATH.clear 1523 $LOAD_PATH.concat [ 1522 ActionController::Routing.controller_paths = [ 1524 1523 RAILS_ROOT, RAILS_ROOT + '/app/controllers', RAILS_ROOT + '/vendor/plugins/bad_plugin/lib' 1525 1524 ] … … 1527 1526 assert_equal ["admin/user", "plugin", "user"], ActionController::Routing.possible_controllers.sort 1528 1527 ensure 1529 if true_load_paths 1530 $LOAD_PATH.clear 1531 $LOAD_PATH.concat true_load_paths 1528 if true_controller_paths 1529 ActionController::Routing.controller_paths = true_controller_paths 1532 1530 end 1533 1531 Object.send(:remove_const, :RAILS_ROOT) rescue nil trunk/railties/CHANGELOG
r4760 r4762 1 1 *SVN* 2 3 * Assign Routing.controller_paths; fix script/about and rails info controller. [Nicholas Seckar] 2 4 3 5 * Don't warn dispatcher of Reloadable deprecations. [Nicholas Seckar] trunk/railties/lib/initializer.rb
r4736 r4762 151 151 # Add the load paths used by support functions such as the info controller 152 152 def add_support_load_paths 153 builtins = File.join(File.dirname(File.dirname(__FILE__)), 'builtin', '*')154 $LOAD_PATH.concat(Dir[builtins])155 153 end 156 154 … … 177 175 config = configuration 178 176 constants = self.class.constants 179 eval(IO.read(configuration.environment_path), binding )177 eval(IO.read(configuration.environment_path), binding, configuration.environment_path) 180 178 (self.class.constants - constants).each do |const| 181 179 Object.const_set(const, self.class.const_get(const)) … … 252 250 def initialize_routing 253 251 return unless configuration.frameworks.include?(:action_controller) 252 ActionController::Routing.controller_paths = configuration.controller_paths 254 253 ActionController::Routing::Routes.reload 255 254 end … … 512 511 end 513 512 513 def builtin_directories 514 # Include builtins only in the development environment. 515 (environment == 'development') ? Dir["#{RAILTIES_PATH}/builtin/*/"] : [] 516 end 517 514 518 private 515 519 def root_path … … 590 594 591 595 paths.concat Dir["#{root_path}/vendor/plugins/*/lib/"] 596 paths.concat builtin_directories 592 597 end 593 598 … … 609 614 610 615 def default_controller_paths 611 [ File.join(root_path, 'app', 'controllers'), File.join(root_path, 'components'), File.join(RAILTIES_PATH, 'builtin', 'controllers') ] 616 paths = [ File.join(root_path, 'app', 'controllers'), File.join(root_path, 'components') ] 617 paths.concat builtin_directories 618 paths 612 619 end 613 620