Huy
Huy

Reputation: 11206

Mongoid - save and update_attribute does not persist

I am trying to update an attribute from a record in my Mongo collection, but the new value isn't being saved.

a = GraphEngine::UserPlace.where(place_id:5000000701039).first
a.place_id = 5000000257690
a.save!
=> true

If I inspect a, the place_id reflects the new value, 5000000257690, but when I load the record again, the new place_id does not persist.

Any idea why this is the case? I've checked to make sure that there isn't a duplicate record.

I've also tried a.update_attribute(:place_id,5000000257690) but no luck either. It returns => true, but the value does not persist.

Upvotes: 5

Views: 2754

Answers (1)

alek
alek

Reputation: 331

Check if place_id is accessible. If not add something like this to the model:

attr_accessible :place_id

Upvotes: 7

Related Questions