通过 MongoMapper 向现有模型(使用现有数据)添加密钥时,我可以使用新密钥创建新文档,但是当尝试使用相同密钥访问现有文档时,它会失败,说明它是“未定义的方法”。
我想知道是否有人有任何见解。
提前致谢!
(是的,这些示例被截断了。)
- model.rb -
key :key_1
key :key_2
- would return -
#<Model _id: BSON::ObjectID('4ba821abebddb9094c000001'), key_1: "test", key_2: "test">
- model.rb (updated version) -
key :key_1
key :key_2
key :key_3
- would still only return -
#<Model _id: BSON::ObjectID('4ba821abebddb9094c000001'), key_1: "test", key_2: "test">
- but if a new doc is created -
#<Model _id: BSON::ObjectID('4ba821abebddb9094c000001'), key_1: "test", key_2: "test">
#<Model _id: BSON::ObjectID('7ba131abedaab9094c007482'), key_1: "test", key_2: "test", key_3: "test">
这会很好,除非我在尝试访问第一个文档的 :key_3 时收到方法未定义错误。
导轨 2.3.4
MongoMapper 0.7.4