diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 6efcb9f9db..06d1419368 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Allow config.to_prepare to work, make the dispatcher safe to 're require'. [Koz, Nicholas Seckar] + * Fix scaffold_resource generator so it respects the --pretend argument when creating the routes file. Closes #6852 [fearoffish] * Fix Webrick Daemon dispatching bug regarding a bad current working directory. Closes #4899 [Rick Olson] diff --git a/railties/lib/dispatcher.rb b/railties/lib/dispatcher.rb index 31eb5d2317..b0ddd29cd3 100644 --- a/railties/lib/dispatcher.rb +++ b/railties/lib/dispatcher.rb @@ -163,7 +163,7 @@ class Dispatcher end end - self.preparation_callbacks = [] + self.preparation_callbacks ||= [] self.preparation_callbacks_run = false end diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 5b529ffc3d..c7f32d767a 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -551,6 +551,7 @@ module Rails # # See Dispatcher#to_prepare. def to_prepare(&callback) + require 'dispatcher' unless defined?(::Dispatcher) Dispatcher.to_prepare(&callback) end