diff options
author | José Valim and Mikel Lindsaar <pair@programming.com> | 2010-01-25 09:50:01 +1100 |
---|---|---|
committer | José Valim and Mikel Lindsaar <pair@programming.com> | 2010-01-25 09:50:01 +1100 |
commit | 4e96442c4e404141830b2d7f0d850b6556190b39 (patch) | |
tree | a3ca088ad9d68b5be9ace4d431375bb3fd4ea045 /actionpack/lib/action_dispatch/routing | |
parent | a74a655648618a6ed568b9b4ef3a17a8970e7774 (diff) | |
parent | 396003fc48d7c0ba206ad059646c7414bee22a36 (diff) | |
download | rails-4e96442c4e404141830b2d7f0d850b6556190b39.tar.gz rails-4e96442c4e404141830b2d7f0d850b6556190b39.tar.bz2 rails-4e96442c4e404141830b2d7f0d850b6556190b39.zip |
Merge branch 'master' of git://github.com/rails/rails
Conflicts:
actionmailer/lib/action_mailer/mail_helper.rb
railties/lib/rails/configuration.rb
Diffstat (limited to 'actionpack/lib/action_dispatch/routing')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 660d28dbec..c49ac70562 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -222,19 +222,18 @@ module ActionDispatch end end - attr_accessor :routes, :named_routes - attr_accessor :disable_clear_and_finalize + attr_accessor :routes, :named_routes, :controller_namespaces + attr_accessor :disable_clear_and_finalize, :resources_path_names def self.default_resources_path_names { :new => 'new', :edit => 'edit' } end - attr_accessor :resources_path_names - def initialize self.routes = [] self.named_routes = NamedRouteCollection.new - self.resources_path_names = self.class.default_resources_path_names + self.resources_path_names = self.class.default_resources_path_names.dup + self.controller_namespaces = Set.new @disable_clear_and_finalize = false end @@ -281,32 +280,19 @@ module ActionDispatch def controller_constraints @controller_constraints ||= begin - source = controller_namespaces.map { |ns| "#{Regexp.escape(ns)}/#{CONTROLLER_REGEXP.source}" } + namespaces = controller_namespaces + in_memory_controller_namespaces + source = namespaces.map { |ns| "#{Regexp.escape(ns)}/#{CONTROLLER_REGEXP.source}" } source << CONTROLLER_REGEXP.source Regexp.compile(source.sort.reverse.join('|')) end end - def controller_namespaces + def in_memory_controller_namespaces namespaces = Set.new - - # Find any nested controllers already in memory ActionController::Base.subclasses.each do |klass| controller_name = klass.underscore namespaces << controller_name.split('/')[0...-1].join('/') end - - # TODO: Move this into Railties - if defined?(Rails.application) - # Find namespaces in controllers/ directory - Rails.application.config.controller_paths.each do |load_path| - load_path = File.expand_path(load_path) - Dir["#{load_path}/**/*_controller.rb"].collect do |path| - namespaces << File.dirname(path).sub(/#{load_path}\/?/, '') - end - end - end - namespaces.delete('') namespaces end |