javan/whenever

Run custom rails module

mvondoyannick opened this issue · 1 comments

Hi!
i need some help, how can run my custom module in whenever.
when a try someting like this :

every 1.minutes do
	puts "testing cron jobs"
  Sms.new(691451189, Time.now)
  Sms.send
end

i receive an error when a type this whenever commande in my project folder (terminal)

$ whenever --update-crontab
testing cron jobs
Traceback (most recent call last):
        11: from /usr/bin/whenever:41:in `<main>'
        10: from /usr/lib/ruby/vendor_ruby/whenever/command_line.rb:6:in `execute'
         9: from /usr/lib/ruby/vendor_ruby/whenever/command_line.rb:35:in `run'
         8: from /usr/lib/ruby/vendor_ruby/whenever/command_line.rb:104:in `updated_crontab'
         7: from /usr/lib/ruby/vendor_ruby/whenever/command_line.rb:54:in `whenever_cron'
         6: from /usr/lib/ruby/vendor_ruby/whenever.rb:10:in `cron'
         5: from /usr/lib/ruby/vendor_ruby/whenever.rb:10:in `new'
         4: from /usr/lib/ruby/vendor_ruby/whenever/job_list.rb:25:in `initialize'
         3: from /usr/lib/ruby/vendor_ruby/whenever/job_list.rb:25:in `instance_eval'
         2: from config/schedule.rb:22:in `initialize'
         1: from /usr/lib/ruby/vendor_ruby/whenever/job_list.rb:44:in `every'
config/schedule.rb:24:in `block in initialize': uninitialized constant #<Class:#<Whenever::JobList:0x00005563bb94b398>>::Sms (NameError)

my module can't be execute. need help please.

my configuration:
Ubuntu Linux 19.04 X64
ruby 2.5.5
rails 5.2.3

You need to wrap your code in a rake task or use runner. The README covers this.