How to monkey patch a rake task shipped with Rails

2019-05-11 21:22发布

问题:

I just found a bug in one of the rake tasks shipped with Rails. Is there a way to monkey patch a rake task?

回答1:

Yes.

You can do something like this:

Rake::Task['doc:app'].clear

and then define your own task

namespace :doc do
  task :app do
    # work your magic
  end
end