The schedule is running but errors "undefined method 'do_something'". What is not right?
Using rails 3.
In config/initializers/task_scheduler.rb:
require 'rubygems'
require 'rufus/scheduler'
scheduler = Rufus::Scheduler.start_new
scheduler.every("10s") do
JobThing.do_something
end
models/job_thing.rb:
Thanksclass JobThing < ActiveRecord::Base
def do_something
puts "something"
end
end
You're trying to call a class-level method from the task_scheduler when you've actually defined an instance method in your JobThing class. You can define a class method as below :
class JobThing < ActiveRecord::Base
def self.do_something
puts "something"
end
end
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