Rails: Problem with has_and_belongs_to_many

F

Felix Natter

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,
 
C

Clifford Heath

Phlip said:
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 Heath.
 
C

Clifford Heath

Phlip said:
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.
 
T

Tim Hunter

Felix said:
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:
http://www.rubyonrails.com/community
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,169
Messages
2,570,915
Members
47,456
Latest member
JavierWalp

Latest Threads

Top