I am writing a whenever runner defined in the Schedule model like this;
def self.scheduled_jobs
jobs = Schedule.where(execution_time <= Time.now )
if !jobs.nil?
jobs.each do |job|
task = Schedule.find(job)
MessageWorker.perform_async(task.message_id, task.lists, task.user_id)
task.destroy
end
end
end
There is something wrong with the query here;
jobs = Schedule.where(execution_time <= Time.now )
And advice on how i can write it well?
in the console the response is ;
NameError: undefined local variable or method
execution_time' for main:Object`
Overall any advice on how to improve the code?
The whenever cron job is here;
set :output, "/log/cron_log.log"
every 5.minute do
runner "Schedule.scheduled_jobs"
end