我收到以下错误消息:
WARN: wrong number of arguments (1 for 2)
我使用了很多binding.pry
,并在def perform
之前或期间将其分解为。如果我在def perform
的内部插入一个binding.pry
,它不会运行binding.pry
,所以它可能与我的defperform有关??我正在使用的代码如下。
工人内部:
class MessageWorker
include Sidekiq::Worker
sidekiq_options retry: false
sidekiq_retries_exhausted do |msg|
Sidekiq.logger.warn "Failed #{msg['class']} with #{msg['args']}: #{msg['error_message']}."
end
def perform(send_time, message_id)
record = Textmessage.find message_id
@twilio = Twilio::REST::Client.new ENV['ACCOUNT_SID'], ENV['AUTH_TOKEN']
@twilio.account.messages.create(
from: ENV['ACCOUNT_PHONE_NUMBER'],
to: record.phone_number,
body: 'Reminder'
)
end
end
让它与以下内容一起工作:
在控制器中:
def create
@textmessage = current_user.textmessages.build(textmessage_params)
if @textmessage.save
MessageWorker.perform_at(@textmessage.date_time, @textmessage.id)
redirect_to houses_path, notice: 'Textmessage Alert Added'
else
# redirect_to house_path(@rating.house), notice: "Error: rating was not added"
redirect_to :back, alert: 'Textmessage Alert Not Added'
end
end