Do I have to create the join tables?


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?

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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs