2014-04-17 9 views
0

我收到以下錯誤信息:Sidekiq和Twilio在工人打破「錯誤的參數數目(1 2)」

WARN: wrong number of arguments (1 for 2) 

我已經使用了很多binding.pry和boilded下來打破權之前或期間def perform。如果我在def perform內部立即插入binding.pry它不會運行binding.pry,所以它可能與我的def執行有關?我正在使用的代碼如下。

裏面的工人的:

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 

回答

0

得到它具有以下工作:

在控制器:

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 
相關問題