使用devise-async发送电子邮件不起作用(Rails / Sidekiq)

时间:2014-05-29 12:52:27

标签: ruby-on-rails devise redis sidekiq devise-async

我的Rails应用中有sidekiq (2.15.2)devise (3.2.0)devise-async (0.9.0)

我想让devise-async接管发送电子邮件。但没有运气。我跟着instructions这样跟着:

:async添加到User型号:

# models/user.rb
class User
  include Mongoid::Document
  devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :confirmable, :async
end

创建初始化程序:

# config/initializers/devise_async.rb
Devise::Async.backend = :sidekiq

我没有在我的邮件中进行任何自定义修改

# config/initializers/devise_async.rb
Devise.setup do |config|
  config.mailer_sender = "my@email.com"
  # config.mailer = "Devise::Mailer"
end

以下是创建新帐户时在控制台中显示的内容:

Started POST "/da/users" for 127.0.0.1 at 2014-05-29 14:42:07 +0200
Processing by RegistrationsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"wyIIRqVoYrXqbX/U+3PGyrYI/MIxcH1YErUQ7JWcfUs=", "user"=>{"company"=>"Some Company Ltd.", "email"=>"some@email.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Opret", "locale"=>"da"}
  MOPED: 127.0.0.1:27017 QUERY        database=mydb_development collection=users selector={"email"=>"some@email.com"} flags=[] limit=-1 skip=0 batch_size=nil fields={:_id=>1} runtime: 0.9300ms
  MOPED: 127.0.0.1:27017 QUERY        database=mydb_development collection=users selector={"$query"=>{"confirmation_token"=>"5bc925b83260b498dfc26e202c1403c39638527b62c85fec7e97c9f59d1f55d8"}, "$orderby"=>{:_id=>1}} flags=[] limit=-1 skip=0 batch_size=nil fields=nil runtime: 0.8670ms
  MOPED: 127.0.0.1:27017 INSERT       database=mydb_development collection=users documents=[{"_id"=>BSON::ObjectId('53872b204368720748000000'), "email"=>"some@email.com", "encrypted_password"=>"$2a$10$6WQO8zK2Sl/HCPPYHIdKceKpaY9gH.LJZlRM8PA.6i2rePmI8C1Ii", "sign_in_count"=>0, "company"=>"Some Company Ltd", "confirmation_token"=>"5bc925b83260b498dfc26e202c1403c39638527b62c85fec7e97c9f59d1f55d8", "confirmation_sent_at"=>2014-05-29 12:42:08 UTC, "locale"=>"da", "timezone"=>"Europe/Copenhagen"}] flags=[]
                     COMMAND      database=mydb_development command={:getlasterror=>1, :w=>1} runtime: 1.0460ms
2014-05-29T12:42:08Z 1864 TID-oxcjnftnc INFO: Sidekiq client using redis://localhost:6379/0 with options {}
Redirected to http://localhost:3000/da/users/confirmation/new
Completed 302 Found in 1469ms

我的Sidekiq日志虽然没有显示任何内容。

有什么想法吗?

1 个答案:

答案 0 :(得分:9)

设置Devise::Async.queue = :default