[英]Sidekiq worker didn't work
I tried to setup a basic notification worker to notify some user. 我试图设置一个基本的通知工作程序来通知某些用户。 But in my example my user didn't get any notifcation.
但是在我的示例中,我的用户没有收到任何通知。
my controller action where I tried to perform my worker: 我尝试执行工作人员的控制器动作:
def index
NotificationWorker.delay().perform(current_user.id, 'error', 'refresh', 'test', 'asd')
# ActionCable.server.broadcast "web_notifications_#{current_user.id}", { type: 'error', icon: 'refresh', title: 'title', body: 'body' }
end
my notification_worker.rb 我的notification_worker.rb
class NotificationWorker
include Sidekiq::Worker
def perform(user_id, type, icon, title, body)
Notification.create(user_id, type, icon, title, body)
end
end
and my notification model: 和我的通知模型:
class Notification < ActiveRecord::Base
# belongs_to
belongs_to :users
def self.create(user_id, type, icon, title, body)
ActionCable.server.broadcast "web_notifications_#{user_id}", { type: 'error', icon: 'refresh', title: 'title', body: 'body' }
end
end
when I use this 当我用这个
Notification.create(current_user.id, 'error', 'refresh', 'test', 'asd')
my user get the notification but I wan't to send them with sidekiq 我的用户收到了通知,但我不想通过sidekiq发送给他们
根据我在评论中的假设-问题是您没有运行sidekiq。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.