Когда я пытаюсь использовать DBRef в рубиновом драйвере mongo (создавая новый объект DBRef и включающий в документ, который Я вставив в коллекцию), я получаю эту ошибку, что я не могу сделать головы, ни хвосты:Использование DBRef в mongo ruby driver: (undefined method `bson_type 'для # <Mongo :: DBRef: 0x0056466ed55e48>)
NoMethodError (undefined method `bson_type' for #<Mongo::DBRef:0x0056466ed55e48>):
app/controllers/payment_notifications_controller.rb:43:in `block in create'
app/controllers/payment_notifications_controller.rb:19:in `create'
Вот код в вопросе:
user_mongo = Urgent::Application.config.mongo_client[:user].find(uuid: order.identity.uuid)
if user_mongo
grant_document = { :target => Mongo::DBRef.new("user", user_mongo.first["_id"]), :role => order_item.expirable.backend_id, :created => Time.now, :store_item_id => order_item.id, :store_order_id => order.id }
if expires
grant_document[:expires] = expires
end
Urgent::Application.config.mongo_client[:grant].insert_one(grant_document)
end
линия 39 относится к второй к последнему в фрагменте кода.