N..N Relationships explicit save of both records?

18 views
Skip to first unread message

brianp

unread,
Oct 2, 2011, 7:10:07 PM10/2/11
to Mongoid
So if i have an N..N relationship between Site and User if i do the
following

@site.create

user = @site.users.new()

user.save

@site will end up with no user in site_ids.

Is it by design that I have to explicitly call save on both the site
and the user for them to store each others id's? I would expect @site
to get some sort of callback to save the user id when the user is
saved. The docs at: http://mongoid.org/docs/relations/referenced/n-n.html
also make it sounds like that's what is supposed to happen.

Cheers

Nick Hoffman

unread,
Oct 5, 2011, 10:20:24 AM10/5/11
to mon...@googlegroups.com
That looks like a bug to me. If I specify
    :autosave => true
on both sides of the relation, the user's ID still isn't added to the site.

Could you report this on GitHub, please?

Thanks!

Nick Hoffman

unread,
Oct 5, 2011, 6:58:33 PM10/5/11
to mon...@googlegroups.com
Brian just created a GitHub issue for this:
Reply all
Reply to author
Forward
0 new messages