gpt4 book ai didi

ruby-on-rails - 尝试发送电子邮件时出现 sidekiq_mailer 错误

转载 作者:数据小太阳 更新时间:2023-10-29 08:20:28 24 4
gpt4 key购买 nike

我在我的应用程序中添加了 gem sidekiq (2.15.0) 和 sidekiq_mailer (0.0.6)。当我尝试发送电子邮件时,我收到:

NoMethodError (undefined method `key?' for #<JSON::Ext::Generator::State:0x007f1b......

有人知道为什么会这样吗?

最佳答案

根据 this comment on a resque issue我能够解决一个类似的问题,我试图将整个对象传递给工作人员的 perform 操作,而不仅仅是对象 ID。我重构了我的代码以仅传递一个 id 并在 worker 中获取必要的对象。

更深层次的问题是 sidekiq 只支持原生 JSON 类型,因此在尝试将对象传递给 sidekiq 时,它会抛出任何更复杂的东西,比如 ruby​​ 对象。参见 this thread有关更多详细信息和文档:

The arguments you pass to perform_async must be composed of simple JSON datatypes: string, integer, float, boolean, null, array and hash. The Sidekiq client API uses JSON.dump to send the data to Redis. The Sidekiq server pulls that JSON data from Redis and uses JSON.load to convert the data back into Ruby types to pass to your perform method. Don't pass symbols or complex Ruby objects (like Date or Time!) as those will not survive the dump/load round trip correctly.

关于ruby-on-rails - 尝试发送电子邮件时出现 sidekiq_mailer 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19158057/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com