jeudi 28 janvier 2021

Cron job and whenever gem

I'm new to rails I am trying to implement cron jon in my app this is my schedule.rb

set :environment, "development"
set :output, "log/cron.log"
every 2.minutes do
    rake 'batch:send_digest_email'
end

this is lib/tasks/email_task.rake

namespace :batch do
  desc 'send digest email'
  task send_digest_email: :environment do
    # ... set options if any
    user = User.last
    # @user.each do |user|
      ExampleMailer.sample_email(user).deliver!
    # end
  end
end

email functionality is working correctly. Implementing using cron jobs is not working. I have run the bundle exec whenever command. This is the logfile

/usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb:50:in `<class:Specification>': undefined method `rubyforge_project=' for class `Gem::Specification' (NameError)
    from /usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb:49:in `<top (required)>'
    from /snap/ruby/201/lib/ruby/3.0.0/rubygems.rb:1348:in `require'
    from /snap/ruby/201/lib/ruby/3.0.0/rubygems.rb:1348:in `<top (required)>'
    from <internal:gem_prelude>:2:in `require'
    from <internal:gem_prelude>:2:in `<internal:gem_prelude>'

Aucun commentaire:

Enregistrer un commentaire