Very late on the show. It uses Mongoid 4.0.2. The problem also bothers me.
The @sandrew link is no longer valid. A similar problem was presented here: http://github.com/mongodb/mongoid/pull/3604
The workaround I found was:
@cali_group.followers = []
@cali_group.follower_ids
@user1.followed_groups << @cali_group
This workaround was discovered by adding before_save to the Group class and abiding self.changes. Without this line, the member follower_idschanges from nilto []. However, after adding the line, the correct user ID is accepted and set. Hope this helps any future reader.
source
share