Forum: Ruby rake: passing args to Task invoke

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
89316fb47af779e33e9d36d08a5eddd6?d=identicon&s=25 Robert Brown (rob99)
on 2009-01-09 04:53
I need to write a rake task that invokes other rake tasks.  Can do that
fine but cannot work out the syntax for tasks that take arguments.

For example db:migrate.  How would I give it a version?

I've tried the following, but the argument is ignored:

Rake::Task['db:migrate'].invoke(:version=>'20090106012227')

Thanks in advance....
Ab0b39142721bf4ab6492bdeb18c9682?d=identicon&s=25 Roger Pack (Guest)
on 2009-01-11 10:52
(Received via mailing list)
> For example db:migrate.  How would I give it a version?
Maybe add to ENV?
-=r
80e4cb97cae5c8d745f72337d93fd8f2?d=identicon&s=25 MaD (Guest)
on 2009-01-12 13:25
(Received via mailing list)
i didn't get that work either. did anyone have success with that?

so far, my personal workaround is to make system-calls (which is not
very nice).
80e4cb97cae5c8d745f72337d93fd8f2?d=identicon&s=25 MaD (Guest)
on 2009-01-14 09:40
(Received via mailing list)
well for db:migrate modifying ENV works very well, but if you want to
pass a certain RAILS_ENV it seems to be impossible from inside an
active rails-app. you'll have to go with system calls.

  system('rake db:drop RAILS_ENV=test')

but

  ENV['VERSION']= '0'
  Rake::Task['db:migrate'].invoke

so far even on tha rake mailing-list no other option occurred.
This topic is locked and can not be replied to.