I'm writing a Rails 3 generator that creates two different models. Here's a very simplified example of what I'm trying to do:
def my_generator_task
invoke "model", ["foo"]
invoke "model", ["bar"]
end
The problem is that the Thor invoke method only invokes a task once, so the second call to the "model" task never happens and the "bar" model is never created. Does anyone know an elegant way to accomplish this, preferably in a way that doesn't break the ability to run "rails destroy" with the generator?
One more thought, this way it is also possible to run multiple model generator without migration
Rails::Generators.invoke("active_record:model", ["foo", "--no-migration" ])
Rails::Generators.invoke("active_record:model", ["bar", "--no-migration" ])
With Thor, if you want to invoke a task withOUT dependency management, you just call it directly:
model(foo)
model(bar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With