我收到此错误“无法将主机名\” postgres \”转换为地址:在尝试调用运动鞋工人中从ActiveRecord :: Base继承的模型时,名称或服务未知。
我们在docker容器中运行Rabbitmq和应用服务器。如果我从应用程序容器中“跟踪c”并访问模型数据,则它可以工作。但是当从运动鞋工作人员调用相同的代码时,它将引发错误。
class MarketServer
include Sneakers::Worker
from_queue 'some_queue',
env: nil,
timeout_job_after: 12.hours
def work_with_params(msg, _headers, params)
begin
data = {}
ActiveRecord::Base.connection_pool.with_connection do
data['market_name'] = Market.last.name
end
Rails.logger.debug 'data built'
ack! # we need to let queue know that message was received
end
end