Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 216
Huy Avatar asked Dec 20 '12 19:12

Huy


1 Answers

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

attr_accessible :place_id
like image 108
alek Avatar answered Sep 29 '22 19:09

alek