Call task more than once in Rails 3 generator

Posted by balexand on Stack Overflow See other posts from Stack Overflow or by balexand
Published on 2010-12-02T02:58:26Z Indexed on 2011/02/05 7:26 UTC
Read the original article Hit count: 417

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?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby