Rails: Problem with has_and_belongs_to_many

hello,

I have an m:n relationsship (has_and_belongs_to_many) between the models
CoreUser and CoreGroup. So from some rails experience I thought I’d
be able to add a (user,group)-relation simply by doing
agroup.core_users << auser.

Unfortunately the following test-case fails on the last assertion
(unless I include the line that is commented out):

def test_add_remove
someuser = CoreUser.create!(:username => ‘test2s’, …)
ag = CoreGroup.find_by_path("/Administrators")
assert !ag.core_users.include?(someuser)
assert !someuser.core_groups.include?(ag)

ag.core_users << someuser

someuser.core_groups << ag

assert ag.core_users.include?(someuser)
assert someuser.core_groups.include?(ag)

end

Shouldn’t it work with the line being commented out (one direction)?

thanks,

Felix N. wrote:

hello,

I have an m:n relationsship (has_and_belongs_to_many) between the models

There’s a whole mailing list dedicated to Ruby on Rails and populated
with people who love to discuss RoR. While there are some Rails-ers
here, you’re going to get a lot more help on the RoR list. Find it here:

Phlip wrote:

Firstly, get on the Goole Ruby-on-Rails Talk forum. I know it’s a pain in
the nuts compared to USENET, but you need the best answers for these
questions.

It’s available as an NNTP feed on news.gmane.org as
gmane.comp.lang.ruby.rails

Clifford H…

Phlip wrote:

It’s available as an NNTP feed on news.gmane.org as
gmane.comp.lang.ruby.rails

And gmane reflects new posts properly back to the list??

The only time I ever tried that with GMain, to a Yahoo group, it didn’t
work, and I never tried again…

Yes, it bounces back a verification email the first time,
and then it just works.