I'm trying to learn ActiveJob and I created a simple job to walk through the process. I'm pretty much stuck on step 1. I've got a my_job.rb file in app/jobs. That file contains this code:
class MyJob < ActiveJob::Base
queue_as :default
def perform(obj)
puts obj
end
end
If I go to my console and type in MyJob, it acts like the class doesn't exist...what am I missing?
:001 > MyJob NameError: uninitialized constant MyJob
Make sure the job's filename ends with "_job.rb".
For example: a job called CheckDropboxAvailableSpaceJob
should have its filename named check_dropbox_available_space_job.rb
, not check_dropbox_available_space.rb
.
Rails won't recognize it as a job if the filename doesn't have "_job" on the end.
I think this was resolved somewhat randomly...I probably restarted my server or something. As far as I can tell, every time a job is edited, the server has to be restarted in order for the changes to be picked up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With