rails/rails — pull request #9647 by rwz (2013-03-10 12:25:09+00:00)
Title: Add load hook for ScaffoldControllerGenerator

I'm trying to fix this bug: https://github.com/rails/jbuilder/pull/100

The only way I see I can fix that is to redefine the ScaffoldControllerGenerator template and add hooks to it. And to do that I need to require a lot of code including `rails/generators`.

The problem is that if I do that in jbuilder gem, it'll create `Rails::Configuration::Generators` instance and skip all custom generator settings specified in other gems.

For example, if I have `jbuilder` and `haml-rails` gems enabled, `jbuilder` requires `rails/generators` just for template/hook, and then, later `haml-rails` is doing `config.generators.template_engine :haml` which never get into `Rails::Generators.options` because it was already initialized earlier.

The other problem is that it loads a lot of generators code even if generators are not needed.

I'm not sure how to proceed here, but one solution would be to add load hook for generator. It'll allow me to augment the generator only when it actually loads, which kinda solves both problems stated above.