Forum: Ruby on Rails Do I have to create the join tables?

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.
psimoes (Guest)
on 2007-06-12 13:27
(Received via mailing list)

Suppose I have the following tables:

table X (

table Y (

And I have a many to many relation between them. So, I put in each of
the tables the "has_and_belongs_to_many". In the real database it
should be a X_Y join table. Do I have to create that table with a
migration or the model will take care of that?
Thorsten (Guest)
on 2007-06-12 13:40
(Received via mailing list)
you have to create it with a migration (or by hand, phpmyadmin, or
some other software)

Model 1: Post
Model 2: Authror

Join table:

Rule for the table name: order of model names alphabetically. both
model names pluralized

generally i suggest has_many_through over has_and_belongs_to_many, as
it let's you access the join  table thorugh it's own model...
This topic is locked and can not be replied to.