Jets CronJob not working

question

#1

Hi, this is my ApplicationJob code.

class ApplicationJob < ActiveJob::Base

** rate “1 minute” # fast rate for initial testing**
** def report**
** puts “test”**
** end**
end

But in jets console, when I run ApplicationJob.perform_now(:report), I am getting this issue.
NoMethodError ( undefined method `report’ for #<ApplicationJob:0x00007fcefbc0e140> )

Could you please help me to fix this issue?
Thank you.


#2
class ApplicationJob < ActiveJob::Base

vs

class ApplicationJob < Jets::Job::Base

Tip: Maybe try the generators to prevent future errors. https://rubyonjets.com/docs/generators/


#3

When I run jets generate job hard

=> Rails app detected: Enabling Jets Afterburner.
create app/jobs/hard_job.rb

But hard_job.rb file is not created.


#4

Oh. Generators don’t work with Afterburner mode. Also Jobs won’t work.

Afterburner mode essentially generates wrapper Jets app and proxies to the Rails app. Docs: https://rubyonjets.com/docs/rails/afterburner/

You can sort of still use Jobs. More info here: How to test an Afterburner job from Lambda test events


#7

Yes, I have checked that post.
I created job file in .jets/project/app/jobs
So it is working now.
Thanks a lot.


#8

Hi, how can I call the method in a helper?

This is my job and helper file.

class ReportJob < Jets::Job::Base
include ApplicationHelper

rate “10 minutes”
def report
send_file
end
end

module ApplicationHelper
def send_file
#function_code
end
end

But I am getting this issue.
NameError ( undefined local variable or method `send_file’ for #<ReportJob:0x00007f824592a3f0> )