i am new in ROR and i am using 'Sidekiq' for scheduling Reminders. i can schedule reminder jobs/messages successfully through "Sidekiq". Here is code of 'reminder.rb'
class Reminder < ActiveRecord::Base
belongs_to :user
belongs_to :status_value
belongs_to :communication
after_create :add_sidekiq_job
# before_destroy :remove_sidekiq_job
def add_sidekiq_job
id = ReminderWorker.perform_at(scheduled_at, {id: self.id.to_s})
# self.update_attributes(job_id: id)
end
def remove_sidekiq_job
queue = Sidekiq::ScheduledSet.new
job = queue.find_job(self.job_id)
job.delete if job
end
def scheduled_at
self.notification_time.to_time.to_i - Time.now.to_i
end
end
and here is code of 'reminderworker.rb' where i can get 'reminder/notification message' by passing the id.
class ReminderWorker
include Sidekiq::Worker
def perform(args)
reminder = Reminder.find(args['id'])
puts "~~~~~Notificaiton~~~~~~~~"
end
end
Everything is working till now but now i want to show notification message (which i can get from 'reminder = Reminder.find(args['id'])') in my notification page . how i can do this?
If you want to show this message on user's page you should use some kind of persisted pub/sub client-server connection, that will be available in sidekiq. In Rails 5 it could be ActionCable, in previous versions of Rails - Faye or something like this.