Rails

How To Execute Rake Tasks More Than Once

Posted by Weston Ganger on December 22, 2016

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:


Posted in Rails and Tagged with rake 


Need help on your next project or application?

I specialize in Ruby-on-Rails, AngularJS, Javascript, Bootstrap, and Hybrid Mobile Apps with Cordova & Ionic.

Contact Me

Recommended Posts