Rails - 设计异步(sidekiq)

时间:2016-10-26 19:40:33

标签: ruby-on-rails devise sidekiq

我正在使用带有sidekiq后端的devise-asyn gem,但是当发送一些电子邮件时,我收到以下错误:

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

devise-async (0.7.0) lib/devise/async/model.rb:27:in `send_devise_notification'

任何想法如何修复它?谢谢!

编辑:

我的一些设置: 我正在使用Rails 5

的Gemfile:

gem 'devise' ,'~> 4.1.0' 
gem 'redis-rails'
gem 'sidekiq'
gem 'sinatra', github: 'sinatra/sinatra', require: false
gem 'devise-async'

devise_async.rb初始化程序:

Devise::Async.setup do |config|
  config.backend = :sidekiq
  config.queue   = :mailer
end

用户类(重命名,称为Usuario):

class Usuario < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :async, :recoverable, :rememberable, :trackable, :validatable
 ...
end

sidekiq.yml config:

:queues:
  - default
  - [mailers, 2]

我正在运行sidekiq:

bundle exec sidekiq --environment development -C config/sidekiq.yml

已经重启了rails server,sidekiq和redis服务器,但仍然得到了同样的错误

1 个答案:

答案 0 :(得分:0)

使用宝石'设计','〜&gt; 4.1.0'

/config/initializers/devise_async.rb

Devise::Async.setup do |config|
  config.backend = :sidekiq
  config.queue   = :mailer
end

/app/models/user.rb

    class User < ActiveRecord::Base
    devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable,   :async, :confirmable 
   end

配置/ sidekiq.yml

:queues:
  - default
  - [mailers, 2]