Fix "rails g migration" not always using migration templates
Normally, this is what's supposed to happen when you invoke rails g generate migration
:
-
Rails.application.load_generators
is called here: https://github.com/rails/rails/blob/v4.2.10/railties/lib/rails/commands/commands_tasks.rb#L129 - This loads the local
generator_templates
path in https://github.com/rails/rails/blob/v4.2.10/railties/lib/rails/generators.rb#L69.
However, when metrics are enabled, the application is eager loaded here
in the initializer. This short-circuits the load_generators
and loads
ActiveRecord::Generators::MigrationGenerator
automatically, so the
custom path is never loaded properly.
We fix this by disabling metrics and eager loading when the migration generators are being used.
Edited by Stan Hu