Undefined method 'rake' for rake task with Rufus Scheduler

55 Views Asked by At

having some trouble setting up Rufus Schedular to perform a rake task. Using Rufus-schedular rather then whenever gem as on windows.

/lib/tasks/api.rake

require 'rake'
namespace :api do
  desc "TODO"
  task update: :environment do
  puts "hello world"
  end
end

/config/schedule.rb

require 'rufus-scheduler'
require 'rake'
require 'lib/tasks/api.rake'

scheduler = Rufus::Scheduler.new

scheduler.every '3s' do
 Rake::Task["api:update"].invoke
end

scheduler.join

Gives the following error: NoMethodError 220 undefined method `rake' for main:Object

0

There are 0 best solutions below