Forum: Ruby on Rails HABTM Relation / Save Question

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
HH (Guest)
on 2006-03-05 00:15
(Received via mailing list)
Ok, so I have two models that HABTM each other.


When creating a new user account, this works:

@company.user_accounts << @user

This works with or without a subsequent save of @company.

And the association is set properly but this does nothing (fails

@user.companies << @company

This fails both when I do and don't save @user afterwards.

I've checked all around and none of the objects are nil.

Strange! Am I doing something wrong? It seems like both should work

This topic is locked and can not be replied to.