In Mongoid 3.0.21, how to get all model attributes as a simple Ruby Hash ?
Calling either #attributes or #raw_attributes returns Moped::BSON::Document . Although it does extend the Hash , several hash methods do not work as expected. In particular, #except returns an unmodified self , not a hash with the given keys, separable .
Update : Moped::BSON::Document correctly inherits Hash behavior. I tried calling attributes with characters, not strings, so #except didn't work. In short: do except('pictures') , not except(:pictures) .
source share