[英]wrong number of arguments (given 1, expected 2) with Resque Worker
I understand the self.perform method needs two arguments and I am passing them in. I can assure you the instance variables have values because I have checked. 我知道self.perform方法需要两个参数,并且将它们传递给我。我可以确保实例变量具有值,因为我已经检查过了。 What can you see am I doing wrong?
您能看出我做错了什么吗?
Controller: 控制器:
Resque.enqueue_to(:high, SendInvitationEmail, user_token: @user.token, invitee_token: @invitee.token)
Worker: 工人:
class SendInvitationEmail
def self.perform(user_token, invitee_token)
Frontend::UserManagementMailer.invitation_email(user_token, invitee_token)
end
end
Error: 错误:
wrong number of arguments (given 1, expected 2) line 3
The issue is that you're passing arguments to enqueue_to
as keyword arguments or a Hash
. 问题是您要将参数传递给
enqueue_to
作为关键字参数或Hash
。
Instead, remove the keys and pass the arguments as such. 相反,请删除键并按原样传递参数。
Resque.enqueue_to(:high, SendInvitationEmail, @user.token, @invitee.token)
Or you could modify the method signature of perform to take in a hash or keyword arguments as 或者,您可以修改perform的方法签名以将哈希或关键字参数作为
class SendInvitationEmail
def self.perform(user_token:, invitee_token:)
Frontend::UserManagementMailer.invitation_email(user_token, invitee_token)
end
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.