How to run rake tasks from console?

后端 未结 5 406
南旧
南旧 2021-01-30 00:37

I want to invoke my rake task from console. Is it doable? if yes, how to do so?

I tried this on console:

require \         


        
5条回答
  •  盖世英雄少女心
    2021-01-30 01:23

    I am using rails 5.x.x, and was in the need the do the same form rails console.
    I have create rake task here-

    app/lib/task_to_execute.rake
    

    Here is the command worked for me-

    Load Rails.application.load_tasks

    Rake::Task['task_to_execute:task_name'].invoke
    

    Worked for me!

提交回复
热议问题