Q:

How to define my own primary key for a MongoDB document using Mongoid

I dont want to use _id as the primary key, but want to define my own key. How can I do it using mongoid given the following mongo object.
class Product
  include Mongoid::Document

end

A:

If you wanted to use key with another name as primary key, then you can't do that. Every document has to have a key named _id, value of which will be primary key index entry.  This is how MongoDB works. 
Value of _id field doesn't have to be an ObjectID, though. You can have whatever you like there (except for array, IIRC).

