[Rake-devel] How to pass arguments to Rake::Task['name'].invoke ?
luislavena at gmail.com
Tue Jan 13 07:17:21 EST 2009
On Tue, Jan 13, 2009 at 9:42 AM, Dominik Mayer <Dominik.Mayer at beagile.de> wrote:
> hallo everyone!
> i already tried to find an answer to this question on google and posted
> it on the ruby-mailing list, but i had no success so far in solving my
> i detail my problem is the following:
> i'm using rake with RubyOnRails and want to invoke a task from inside
> another task. at the moment i do this with system calls like the
> system 'rake db:migrate VERSION=0'
> `rake db:drop RAILS_ENV=test`
> what i try to do now is something like that (inside another rake-task):
> Rake::Task['db:migrate'].invoke(:version => 0) # to pass VERSION=0
> Rake::Task['db:drop'].execute(RAILS_ENV, test)
> nothing has worked so far. arguments get ignored or result in errors.
> what's the right way to do such a thing?
If you check the task source code, you will see it uses ENV to find
Because of that, you cannot invoke or execute the task in the way
you're doing. Instead you should:
ENV['VERSION'] = '0'
If Rails update the task to take paramenters, you could invoke it with
the first syntax you tried.
Hope it helps,
Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry
More information about the Rake-devel