Home > OS >  Unable to build simple Rake Task
Unable to build simple Rake Task

Time:09-23

I have created a Rake Task, called update_zendesk_rake.rb file, but every time I try to run it with the command

rake zendesk:update_zendesk_rake 

I receive the error:

    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>'

Nor does it show up when I list available tasks, which leads me to believe it's broken, however, I can't see where the error is.

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

CodePudding user response:

From to the 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.

That means your file should be named like this:

lib/tasks/update_zendesk.rake

Note the file extension .rake instead of .rb.

  • Related