Rails: connecting to an ORM generator

I want to run the generator from gem whenever the model generator is called.

Following

require 'rails' module Mygenerator class Railtie < Rails::Railtie config.app_generators.orm :my_generator end end 

correctly calls my generator, but the native Rails generator no longer starts.

I guess I could run my own generator through invoke , but that seems too complicated. What about all the other ORM generators?

Is there a better way to β€œattach” my generator to an existing one?


Update:

This naturally works, but I still hope for something cleaner:

 module Rails module Generators class ModelGenerator < NamedBase def run_my_custom_generator invoke "my_generator:foo" end end end end 
+7
source share
1 answer

How about something like this

 require 'rails' class Rails::Generators::ModelGenerator include Mygenerator::full_namespace_here::class extend Mygenerator::full_namespace_here::ClassMethods end 
0
source

All Articles