How do I run rake tasks within my rails application

后端 未结 5 921
青春惊慌失措
青春惊慌失措 2020-12-24 08:47

What I want to do:

In a model.rb, in after_commit, I want to run rake task ts:reindex

ts:reindex is normally run with a rake ts:index

5条回答
  •  暖寄归人
    2020-12-24 09:26

    require 'rake'
    RailsApp::Application.load_tasks
    class SomeModel 

    And then just use SomeModel.run_rake("ts:reindex").

提交回复
热议问题