Delayed_job not saving in database

By : evoo
Source: Stackoverflow.com
Question!

I am using Ruby on Rails and trying to add a feature for scheduling notification push by using delayed job. I implemented the gem as per documentation and started workers by running rake jobs:work but despite my best efforts, no job is being saved. I tried Delayed::Job.all in the console but it returns an empty array no matter what I do.

my model:

class MessageSocialAccount < ActiveRecord::Base
  attr_accessible :social_account_id, :message_id, :read_time, :push_notification
  attr_reader :when_to_run
  belongs_to :message
  belongs_to :social_account

  def when_to_run
    message.deliver_at || Time.now
  end

  def push
    social_account.send_push(msg_sca.message)
    update_attributes!(:push_notification => true)
  end
  handle_asynchronously :push, :run_at => Proc.new {|i| i.when_to_run }
end

I can see no delayed_job.log in the logs and development.log does not contain any clues.

Would you have any ideas what the problem might be? Thanks

*EDIT the model that I am calling it from: message.rb

class Message < ActiveRecord::Base
  def send_push_to_all(delivery_time=nil)
    self.message_social_accounts.map{|msg_sca| msg_sca.push} unless self.reward.status=="qa"
    self.update_attributes!(:sent_at => Time.now)
  end
end

The call comes from the controller:

msg.send_push_to_all(msg.deliver_at)
By : evoo


Answers

I realised that the app I was working on had already implemented Sidekiq for another purpose and looks like those 2 interfered. When the Sidekiq interface was opened I could see the jobs in there eventhough they were not showing in the delayed job queries.

By : evoo


This video can help you solving your question :)
By: admin