1

I am performing some tests in a Ruby on Rails application using Whenever gem.

Is it possible to access Models from the schedule.rb file ?!

For example:

#Hard Worker
job = Job.find_by(name: 'Hard')

if job.status == 'active'
  every 4.minutes do
    runner 'HardWorker.perform_async'
  end
end

Just checked this and I encountered this error:

config/schedule.rb:2:in `initialize': undefined method `find_by' for Whenever::Job:Class (NoMethodError)

Many thanks !

Stefan Ciprian Hotoleanu
  • 2,202
  • 1
  • 23
  • 30

0 Answers0