# Rake: passing args to Task invoke

**URL:** <https://www.ruby-forum.com/t/rake-passing-args-to-task-invoke/157280>\
**Category:** Ruby\
**Created:** [January 9, 2009, 4:53am UTC](https://www.ruby-forum.com/t/rake-passing-args-to-task-invoke/157280 "2009-01-09T04:53:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rjberry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/34f0e0/32.png) [@rjberry](https://www.ruby-forum.com/u/rjberry)\
**Post date:** [January 9, 2009, 4:53am UTC](https://www.ruby-forum.com/t/rake-passing-args-to-task-invoke/157280/1 "2009-01-09T04:53:09Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![rjberry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/34f0e0/32.png) [@rjberry](https://www.ruby-forum.com/u/rjberry)\
**Post date:** [January 11, 2009, 10:52am UTC](https://www.ruby-forum.com/t/rake-passing-args-to-task-invoke/157280/2 "2009-01-11T10:52:30Z")

</div>

> For example db:migrate. How would I give it a version?  
> Maybe add to ENV?  
> -=r

---

<div class="post-metadata">

**Author:** ![rjberry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/34f0e0/32.png) [@rjberry](https://www.ruby-forum.com/u/rjberry)\
**Post date:** [January 12, 2009, 1:25pm UTC](https://www.ruby-forum.com/t/rake-passing-args-to-task-invoke/157280/3 "2009-01-12T13:25:52Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![rjberry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/34f0e0/32.png) [@rjberry](https://www.ruby-forum.com/u/rjberry)\
**Post date:** [January 14, 2009, 9:40am UTC](https://www.ruby-forum.com/t/rake-passing-args-to-task-invoke/157280/4 "2009-01-14T09:40:59Z")

</div>

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.
