I trying to get mongoid to save associations, but I can only get one side to work. If I have the following test.
test "should add a user as a follower when a user follows the group" do
@cali_group.followers = []
@user1.followed_groups << @cali_group
assert_equal 1, @user1.followed_groups.count
assert_equal 1, @cali_group.followers.count
end
Which is failing, because @cali_group.followers is []. I've been working with this for awhile, tried @cali_group.reload
. But it looks like the only way to do this in my code is to work both ends of the join, i.e. @cali_group.followers << @user1
. I can do that in my code if I have to.
The models for polco_group and user are here: https://gist.github.com/1195048
Full test code is here: https://gist.github.com/1195052
It can be that: https://github.com/mongoid/mongoid/issues/1204
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With