Mongoid - save和update_attribute不会保留

Huy*_*Huy 5 ruby ruby-on-rails mongodb ruby-on-rails-3 mongoid3

我正在尝试从Mongo集合中的记录更新属性,但是没有保存新值.

a = GraphEngine::UserPlace.where(place_id:5000000701039).first
a.place_id = 5000000257690
a.save!
=> true
Run Code Online (Sandbox Code Playgroud)

如果我检查a,则place_id反映新值,5000000257690但是当我再次加载记录时,新的place_id不会持久存在.

知道为什么会这样吗?我已经检查过以确保没有重复的记录.

我也试过a.update_attribute(:place_id,5000000257690)但也没有运气.它返回=> true,但值不会持续.

小智 7

检查place_id是否可访问.如果没有添加这样的东西到模型:

attr_accessible :place_id
Run Code Online (Sandbox Code Playgroud)