2
當我嘗試在mongo ruby驅動程序中使用DBRef時(創建一個新的DBRef對象並在文檔中包含我插入的集合),我得到這個錯誤,我不能做的頭,也沒有尾巴:在mongo ruby驅動程序中使用DBRef:(undefined method`bson_type'for#<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'
這裏是有問題的代碼:39
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
線指的是倒數第二在代碼片段中。