Saturday 9 August 2014

Sequential Rake tasks

If you are developing in Rails, chances are that you at some point would like to run Ruby code as Rake tasks. This may be a little bit tricky especially when you have sequential tasks with dependencies.

In this post I will explain how to run multiple rake tasks in sequence:

1./ Create an empty file in lib/tasks

2./ Name the file Something.rake (the .rake suffix is important).

3./ Then fill out your Ruby code within tasks, like so:


4./ Then run your rake task from the root of your Rails application:


and your rake tasks are performed in sequence.

Learn more about this subject from Ryan Bates at Railscasts or from Łukasz Wróbel.


No comments:

Post a Comment