私のレール4アプリに複数のsidekiqワーカーがいて、なぜプロセスが失敗しているのか分かりません。 User_idを文字列としてワーカーに渡していますが、ユーザーを見つけることができないようです。しかし、私は自分のコンソールで同じIDを検索すると、ユーザーを見つけます。何が間違っているのですか?ここに私のコードです。Rails Sidekiq ERROR:オブジェクトを見つけることができません
Controller.rb
def update
@user = current_user
if @user.bill.update_attributes(bill_params)
RandomWorker.perform_async(@user.id.to_s)
redirect_to users_dashboard_path, :notice => "Payment Informaton Updated"
else
...
end
end
Randomworker.rb
def perform(user_id)
user_id = user_id["$oid"] unless user_id.is_a?(String)
user = User.find(user_id)
user.process.update_report
user.process.save
end
私のエラーが
RandomWorker "575a..." Mongoid::Errors::DocumentNotFound: message: Document(s) not found for class User with id(s) 575a.... summary: When calling User.find with an id or array of ids, each parameter...
--EDIT--
マイデシベルの設定ファイルがあるとして戻ってきます示されるように:
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
production:
adapter: sqlite3
database: db/production.sqlite3
pool: 25
timeout: 5000
そして、私のmongoid.yml
development:
# Configure available database clients. (required)
clients:
# Defines the default client. (required)
default:
# Defines the name of the default database that Mongoid can connect to.
# (required).
database: development_db
# Provides the hosts the default client can connect to. Must be an array
# of host:port pairs. (required)
hosts:
- localhost:27017
options:
問題を修正しているようですおそらく 'user_id'は正しいです(AFAIK)は' perform_async'呼び出しから来ていて、途中でユーザーを削除するものはありません(右?)。 sidekiqはあなたのアプリと同じデータベースと対話していますか? –
@muistooshort何もユーザーを削除せず、右のdbと話していると思います。だから、同じdbと話していることをどうすれば確認できますか? – SupremeA
私はsidekiqについて何も知らないので、設定をどこから得るのか分かりません。あなたはsidekiqジョブの中の 'Mongoid.default_session'を見て、それが正しい設定をしているかどうかを見ることができます。あなたは 'user_id'を見て、あなたが期待しているものであることを確認することもできます。 –