Rails Delayed Jobs NoMethodError: Undefined Method `prefix

Rails Delayed Jobs NoMethodError: Undefined Method `prefix

我在 class 方法上收到延迟作业的错误:

FAILED (0 prior attempts) with NoMethodError: undefined method `prefix' for #<Object:0x007f9801e1d548>

这是异步方法:

class << self
    def new_request(users, api_client)
      api_client.create_async_call({
        subject: 'subject',
        body: 'body',
        recipients: [user1, user2...]
      })
    end
    handle_asynchronously :new_request
end

我是这样调用方法的:

Notification.new_catalog_request(users, api_client)

我查看了有关延迟作业的自述文件并查看了其他 Whosebug 答案,其中 none 有效。

我需要做什么才能将此异步作业发送到 运行?

很可能您的 api_client 没有在作业中正确序列化和反序列化。您可能更幸运地传递必要的数据,并从作业中重新实例化 api_client 对象,而不是依赖于序列化版本。