How to monkey patch a rake task shipped with Rails?

江枫思渺然 提交于 2019-12-07 12:43:12

问题


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


来源:https://stackoverflow.com/questions/2412627/how-to-monkey-patch-a-rake-task-shipped-with-rails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!