Execute Rake Tasks More Than Once

Posted By Weston Ganger

I wanted to execute a rake task more than one time inside another rake task. Apparently you cannot just simply do this which is weird. You have to re-enable the task again.

# this will not work
Rake::Task["my_task"].invoke(n,other_arg)
Rake::Task["my_task"].invoke(n,other_arg)


# this will work
Rake::Task["my_task"].invoke(n,other_arg)
Rake::Task["my_task"].reenable
Rake::Task["my_task"].invoke(n,other_arg)

Related External Links:

Article Topic:Software Development - Ruby / Rails

Date:December 22, 2016