Question

I am receiving the following error message:

WARN: wrong number of arguments (1 for 2)

I have used a lot of binding.pry and boilded it down to breaking right before or during def perform. If I insert a binding.pry immediately inside of the def perform it does not run the binding.pry, so it is likely something to do with my def perform?? The code that I am using is as follows.

Inside of the Worker:

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
Was it helpful?

Solution

Got it working with the following:

In the Controller:

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top