今天更新了 mongoid 的 master 版本,jbuilder 里的 id 全变成$oid,mongoid 的官方文档说
if you had not been converting your object ids to strings and were storing them in any way that would cause a Marshal dump, you may need to restore these values as strings
然后有个方案是
class Band
include Mongoid::Document
field :_id,
type: String,
pre_processed: true,
default: ->{ Moped::BSON::ObjectId.new.to_s }
end
这样做怎么感觉很 2 啊,等于一个数据存了两份,而且 还得进行数据迁移。。。大家有更好的办法吗