I created a scaffolding gem that uses another gem to generate presenters. I created this scaffolding generator using the Rails 3 generators. It works like this:
rails g stager:scaffold User
I created another gem to generate presenters. I want to use this gem to generate a presenter with each scaffold. Currently I’m doing the following to accomplish this:
run "rails g exhibit:presenter #{scaffold_name}"
The problem is that it seems to reload the Rails environment when this generator is called, making it a bit slow. I’m wondering if there’s a better way to call another generator within a generator. So: is there a better way to create a Rails generator inception? 😉
You must define a
hook_forthe other generator in your generator class. TheScaffoldGeneratoris probably the best example of this, as it has a hook for thescaffold_controllergenerator.If you want to pass in arguments to your generator, it’s probably better to use something like the
hook_forexamples further down in this file for assets and stylesheet engine.