aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/CHANGELOG3
-rw-r--r--actionpack/lib/action_controller/routing.rb17
-rw-r--r--actionpack/test/controller/routing_test.rb10
-rw-r--r--railties/CHANGELOG2
-rw-r--r--railties/lib/initializer.rb15
5 files changed, 28 insertions, 19 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index fae6400849..ff636b7984 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,9 +1,12 @@
*SVN*
+* Add controller_paths variable to Routing. [Nicholas Seckar]
+
* Fix assert_redirected_to issue with named routes for module controllers. [Rick Olson]
* Tweak RoutingError message to show option diffs, not just missing named route significant keys. [Rick Olson]
+>>>>>>> .r4761
* Invoke method_missing directly on hidden actions. Closes #3030. [Nicholas Seckar]
* Require Tempfile explicitly for TestUploadedFile due to changes in class auto loading. [Rick Olson]
diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb
index e4d8253714..8c85c712a0 100644
--- a/actionpack/lib/action_controller/routing.rb
+++ b/actionpack/lib/action_controller/routing.rb
@@ -50,6 +50,10 @@ module ActionController
module Routing
SEPARATORS = %w( / ; . , ? )
+ # The root paths which may contain controller files
+ mattr_accessor :controller_paths
+ self.controller_paths = []
+
class << self
def with_controllers(names)
use_controllers! names
@@ -58,7 +62,7 @@ module ActionController
use_controllers! nil
end
- def normalize_paths(paths = $LOAD_PATH)
+ def normalize_paths(paths)
# do the hokey-pokey of path normalization...
paths = paths.collect do |path|
path = path.
@@ -80,16 +84,15 @@ module ActionController
unless @possible_controllers
@possible_controllers = []
- paths = $LOAD_PATH.select { |path| File.directory?(path) && path != "." }
+ paths = controller_paths.select { |path| File.directory?(path) && path != "." }
seen_paths = Hash.new {|h, k| h[k] = true; false}
normalize_paths(paths).each do |load_path|
Dir["#{load_path}/**/*_controller.rb"].collect do |path|
next if seen_paths[path.gsub(%r{^\.[/\\]}, "")]
-
+
controller_name = path[(load_path.length + 1)..-1]
- next unless path_may_be_controller?(controller_name)
-
+
controller_name.gsub!(/_controller\.rb\Z/, '')
@possible_controllers << controller_name
end
@@ -101,10 +104,6 @@ module ActionController
@possible_controllers
end
- def path_may_be_controller?(path)
- path !~ /(?:rails\/.*\/(?:examples|test))|(?:actionpack\/lib\/action_controller.rb$)|(?:app\/controllers)/o
- end
-
def use_controllers!(controller_names)
@possible_controllers = controller_names
end
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb
index 93eded194e..4c3a910bcd 100644
--- a/actionpack/test/controller/routing_test.rb
+++ b/actionpack/test/controller/routing_test.rb
@@ -1514,21 +1514,19 @@ end
class RoutingTest < Test::Unit::TestCase
def test_possible_controllers
- true_load_paths = $LOAD_PATH.dup
+ true_controller_paths = ActionController::Routing.controller_paths
ActionController::Routing.use_controllers! nil
Object.send(:const_set, :RAILS_ROOT, File.dirname(__FILE__) + '/controller_fixtures')
- $LOAD_PATH.clear
- $LOAD_PATH.concat [
+ ActionController::Routing.controller_paths = [
RAILS_ROOT, RAILS_ROOT + '/app/controllers', RAILS_ROOT + '/vendor/plugins/bad_plugin/lib'
]
assert_equal ["admin/user", "plugin", "user"], ActionController::Routing.possible_controllers.sort
ensure
- if true_load_paths
- $LOAD_PATH.clear
- $LOAD_PATH.concat true_load_paths
+ if true_controller_paths
+ ActionController::Routing.controller_paths = true_controller_paths
end
Object.send(:remove_const, :RAILS_ROOT) rescue nil
end
diff --git a/railties/CHANGELOG b/railties/CHANGELOG
index 294e961f28..2735a462cf 100644
--- a/railties/CHANGELOG
+++ b/railties/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Assign Routing.controller_paths; fix script/about and rails info controller. [Nicholas Seckar]
+
* Don't warn dispatcher of Reloadable deprecations. [Nicholas Seckar]
* Rearrange application resetting and preparation, fix bug with leaking subclasses hash in ActiveRecord::Base [Rick Olson]
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb
index d7cb740dcb..6254c6169f 100644
--- a/railties/lib/initializer.rb
+++ b/railties/lib/initializer.rb
@@ -150,8 +150,6 @@ module Rails
# Add the load paths used by support functions such as the info controller
def add_support_load_paths
- builtins = File.join(File.dirname(File.dirname(__FILE__)), 'builtin', '*')
- $LOAD_PATH.concat(Dir[builtins])
end
# Loads all plugins in <tt>config.plugin_paths</tt>. <tt>plugin_paths</tt>
@@ -176,7 +174,7 @@ module Rails
silence_warnings do
config = configuration
constants = self.class.constants
- eval(IO.read(configuration.environment_path), binding)
+ eval(IO.read(configuration.environment_path), binding, configuration.environment_path)
(self.class.constants - constants).each do |const|
Object.const_set(const, self.class.const_get(const))
end
@@ -251,6 +249,7 @@ module Rails
# loading module used to lazily load controllers (Configuration#controller_paths).
def initialize_routing
return unless configuration.frameworks.include?(:action_controller)
+ ActionController::Routing.controller_paths = configuration.controller_paths
ActionController::Routing::Routes.reload
end
@@ -511,6 +510,11 @@ module Rails
Dispatcher.to_prepare(&callback)
end
+ def builtin_directories
+ # Include builtins only in the development environment.
+ (environment == 'development') ? Dir["#{RAILTIES_PATH}/builtin/*/"] : []
+ end
+
private
def root_path
::RAILS_ROOT
@@ -589,6 +593,7 @@ module Rails
).map { |dir| "#{root_path}/#{dir}" }.select { |dir| File.directory?(dir) }
paths.concat Dir["#{root_path}/vendor/plugins/*/lib/"]
+ paths.concat builtin_directories
end
def default_log_path
@@ -608,7 +613,9 @@ module Rails
end
def default_controller_paths
- [ File.join(root_path, 'app', 'controllers'), File.join(root_path, 'components'), File.join(RAILTIES_PATH, 'builtin', 'controllers') ]
+ paths = [ File.join(root_path, 'app', 'controllers'), File.join(root_path, 'components') ]
+ paths.concat builtin_directories
+ paths
end
def default_dependency_mechanism