Using devise-async to send out emails does not work (Rails/Sidekiq)

房东的猫 提交于 2019-12-08 07:21:49

问题


I have sidekiq (2.15.2), devise (3.2.0) and devise-async (0.9.0) in my Rails app.

I am trying to get devise-async to take over sending out emails. but without luck. I have followed the instructions like this:

Add :async to User model:

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

Create an initializer:

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

I have not made any custom modificationsin my mailer

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

Here is what shows in the console when creating a new account:

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

My Sidekiq log does not show anything though.

Any ideas?


回答1:


Set Devise::Async.queue = :default.



来源:https://stackoverflow.com/questions/23933788/using-devise-async-to-send-out-emails-does-not-work-rails-sidekiq

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!