无法构建简单的 Rake 任务

Unable to build simple Rake Task

我创建了一个 Rake 任务,名为 update_zendesk_rake.rb 文件,但每次我尝试使用命令 运行 它

rake zendesk:update_zendesk_rake 

我收到错误:

    rake aborted!
Don't know how to build task 'zendesk:update_zendesk_rake' (See the list of available tasks with `rake --tasks`)
/Users/conorquarry/.rvm/gems/ruby-2.5.1/gems/rake-13.0.3/lib/rake/task_manager.rb:59:in `[]'
/Users/conorquarry/.rvm/gems/ruby-2.5.1/gems/rake-13.0.3/lib/rake/application.rb:159:in `invoke_task'
/Users/conorquarry/.rvm/gems/ruby-2.5.1/gems/rake-13.0.3/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/Users/conorquarry/.rvm/gems/ruby-2.5.1/gems/rake-13.0.3/lib/rake/application.rb:116:in `each'
/Users/conorquarry/.rvm/gems/ruby-2.5.1/gems/rake-13.0.3/lib/rake/application.rb:116:in `block in top_level'
/Users/conorquarry/.rvm/gems/ruby-2.5.1/gems/rake-13.0.3/lib/rake/application.rb:125:in `run_with_threads'
/Users/conorquarry/.rvm/gems/ruby-2.5.1/gems/rake-13.0.3/lib/rake/application.rb:110:in `top_level'
/Users/conorquarry/.rvm/gems/ruby-2.5.1/gems/rake-13.0.3/lib/rake/application.rb:83:in `block in run'
/Users/conorquarry/.rvm/gems/ruby-2.5.1/gems/rake-13.0.3/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/conorquarry/.rvm/gems/ruby-2.5.1/gems/rake-13.0.3/lib/rake/application.rb:80:in `run'
/Users/conorquarry/.rvm/gems/ruby-2.5.1/gems/rake-13.0.3/exe/rake:27:in `<top (required)>'
/Users/conorquarry/.rvm/gems/ruby-2.5.1/bin/rake:23:in `load'
/Users/conorquarry/.rvm/gems/ruby-2.5.1/bin/rake:23:in `<main>'
/Users/conorquarry/.rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:22:in `eval'
/Users/conorquarry/.rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:22:in `<main>'

当我列出可用任务时它也没有显示,这让我相信它坏了,但是,我看不出错误在哪里。

app/_modules/ccenter/rake/update_zendesk_rake.rb

   namespace :zendesk do
  desc 'update status group values'
  task update_zendesk_rake: :environment do

    the_map = {
      "yssse_ra"=>"legal",
      "active"=>"active",
      "after"=>"legal",
      
    }

    the_map.each { |k,v| CaseFileStatus.where(state: k).update_all(zendesk_status_group: v) }
  end
end

从到 Rails guides about Custom Rake tasks:

Custom rake tasks have a .rake extension and are placed in Rails.root/lib/tasks. You can create these custom rake tasks with the bin/rails generate task command.

这意味着您的文件应该这样命名:

lib/tasks/update_zendesk.rake

请注意文件扩展名 .rake 而不是 .rb