setting mongoid hash field values
问题 I'm using Mongoid in a Rails project (both 4.0.x), and I've got a document with a hash field that stores some schema-less data. class Thing field :name, type: String field :mass, type: Integer field :info, type: Hash end With this setup, I can query for things, say, that have a key :endDate like so: Thing.where("info.endDate"=>{'$exists'=>true}) And that's all nice and handy. Using a hash field for this :info field is nice because what I want to store doesn't have a fixed schema and varies