Search code examples
ruby-on-railsdevisesidekiq

Usind Sidekiq for Devise registration confirmation email


In my model/user.rb I have the following overwrite:

  def send_on_create_confirmation_instructions
    Devise::Mailer.delay.confirmation_instructions(self)
  end

It gets called when someone registers but throws this error:

ArgumentError: wrong number of arguments (given 1, expected 2..3)

while this is the last line of the stack trace:

lib/ruby/gems/2.3.0/gems/devise-4.0.1/app/mailers/devise/mailer.rb:5:in `confirmation_instructions'

Whis is this method:

def confirmation_instructions(record, token, opts={})
  @token = token
  devise_mail(record, :confirmation_instructions, opts)
end

Clearly I'm passing the record, but not the token. I can't figure out where to get it from, in order to pass it, though. What am I missing?


Solution

  • Why are you call confimation_instruction directly. Try next: User.find(1).send_confirmation_instructions

    https://github.com/plataformatec/devise/blob/bacd9d244cdf223b1fe080fa01b8c5bfc0b7a181/lib/devise/models/confirmable.rb#L41

    It's takes care about token.