diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 0f33b40a13..98da7e2b4a 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -166,7 +166,7 @@ module Rails paths.app.controllers.to_a.each do |load_path| load_path = File.expand_path(load_path) Dir["#{load_path}/*/**/*_controller.rb"].collect do |path| - namespace = File.dirname(path).sub(/#{load_path}\/?/, '') + namespace = File.dirname(path).sub(/#{Regexp.escape(load_path)}\/?/, '') app.routes.controller_namespaces << namespace unless namespace.empty? end end