I’ve got an array of referenced objects in a Mongoid document. Using current_user.add_to_set(:whatever, @object.id) works just fine, adding an BSON ObjectId element to the array and saving current_user.
However, when I try to remove the element with pull_all, it’s doesn’t work. Nothing seems to happen:
current_user.pull_all(:whatever, BSON::ObjectId(@object.id))
Any idea what I’m doing wrong?
Thanks!
You need to wrap the items you want to
pull_allin an array, I ran something (in Mongoid 2.0.2) similar to this and it worked fine:That way, you can also specify multiple ids to remove, in one operation, thusly: