class Student < CouchRest::Model::Base
collection_of :phones
def add_phone(new_phone)
#this does not work
#new_phone_ids_list = phone_ids << new_phone.id
#this works
new_phone_ids_list = phone_ids + [new_phone.id]
self.update_attributes(:phone_id => new_phone_ids_list)
end
end
The difference is when I use phone_ids << new_phone.id to create a new list and update couchdb, it doesn't work. But if I use phone_ids + [new_phone.id] ,updates will work. I understand phone_ids + [new_phone.id]
will return a new instance, but cannot figure out why phone_ids << new_phone.id
doesnt work
From the documentation:
Any manual changes made to the collection ids property (group_ids), unless replaced, will require a reload of the CollectionOfProxy for the two sets of data to be in sync