Alex Rivera | Logout

Call task more than once in Rails 3 generator

Asked 2010-12-02T02:58:26.383
10

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?

Edit
Report

1 Answer

2

With Thor, if you want to invoke a task withOUT dependency management, you just call it directly:

model(foo)
model(bar
answered 2011-02-05T07:17:56.040

Your Answer