Overriding rails’ default rake tasks

If you define a rake task that already exists, its execution gets appended to the original task’s execution; both tasks will be executed.

If you want to redefine a task you need to clear the original task first:

Rake::Task["db:test:prepare"].clear

It’s also useful to note that once a task has been executed in rake, it won’t execute again even if you call it again. This is by design but you can call .reset on a task to allow it to be run again.

Leave a Comment