diff options
Diffstat (limited to 'railties/lib')
4 files changed, 10 insertions, 14 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index ce3ab9147c..242aea1842 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -412,18 +412,6 @@ module Rails end end - # Configure generators if they were already loaded - # === - # TODO: Does this need to be an initializer here? - initializer :initialize_generators do - if defined?(RAILS_GENERATORS) && RAILS_GENERATORS - require 'rails/generators' - Rails::Generators.no_color! unless config.generators.colorize_logging - Rails::Generators.aliases.deep_merge! config.generators.aliases - Rails::Generators.options.deep_merge! config.generators.options - end - end - # For each framework, search for instrument file with Notifications hooks. # initializer :load_notifications_hooks do diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb index a6a59f039f..fa2c11795b 100644 --- a/railties/lib/rails/generators.rb +++ b/railties/lib/rails/generators.rb @@ -72,6 +72,12 @@ module Rails } } + def self.configure!(config = Rails.application.config.generators) #:nodoc: + no_color! unless config.colorize_logging + aliases.deep_merge! config.aliases + options.deep_merge! config.options + end + def self.aliases #:nodoc: @aliases ||= DEFAULT_ALIASES.dup end diff --git a/railties/lib/rails/generators/rails/app/templates/script/destroy.tt b/railties/lib/rails/generators/rails/app/templates/script/destroy.tt index 62a856d338..6adc90b2c3 100755 --- a/railties/lib/rails/generators/rails/app/templates/script/destroy.tt +++ b/railties/lib/rails/generators/rails/app/templates/script/destroy.tt @@ -1,4 +1,5 @@ <%= shebang %> -RAILS_GENERATORS = true require File.expand_path('../../config/environment', __FILE__) +require 'rails/generators' +Rails::Generators.configure! require 'rails/commands/destroy' diff --git a/railties/lib/rails/generators/rails/app/templates/script/generate.tt b/railties/lib/rails/generators/rails/app/templates/script/generate.tt index a005e77104..71d47dec92 100755 --- a/railties/lib/rails/generators/rails/app/templates/script/generate.tt +++ b/railties/lib/rails/generators/rails/app/templates/script/generate.tt @@ -1,4 +1,5 @@ <%= shebang %> -RAILS_GENERATORS = true require File.expand_path('../../config/environment', __FILE__) +require 'rails/generators' +Rails::Generators.configure! require 'rails/commands/generate' |