I'm using Mongoid 4.0.0 with Rails 4. My models map tables in another application, and I have no control over the field names.
One of the models has a field named id
, which is getting coerced into Mongo's _id
field. For example, when I insert a document with an id
value of "something"
I get
{_id:"something", id:null}
instead of
{_id:ObjectId("<hexstring>"),id:"something"}
Is there any way to avoid this coercion, make Mongoid not conflate the two fields, and leave my id
field alone?
As I said, renaming the id
field is not an option.
Thanks!
[edited] This is definitely not a MongoDB issue. It must be in Moped or (my guess) Mongoid.
I've tried changing the params
key from :id
to :_rid
but this is still happening. I'm going to check out aliases, but from my first pass I don't think they're going to help -- they appear to go the wrong way.