i setup a relationship using has_and_belongs_to_many to associate users and events. Then I try this:
user = User.find(1)
event = Event.find(1
)
both of these are not currently associated…then I try to associate them by doing:
user.events << event
this action works…however, they don’t associate correctly for each other:
user.events lists the event correctly for this user…but event.users does not have that user associated with it.
how do I make it so that when I associate one with the other (either the event with user or user with event)…it automatically associates the other way?
Is the
has_and_belongs_to_manypresent in both models? It sounds like it is not, whereas it should be: