This blog is part of our Rails 5 series.
In Rails 4.x create_join_table allows us to create new join table with name given in first two arguments.
It will create new join table
customer_products with columns
We can also use block with
create_join_table won’t allows us to define the column type.
It will always create column of
Because Rails 4.x ,by default, supports primary key column type as an auto increment
If we wish to set
uuid as a column type, then
create_join_table won’t work.
In such case we have to create join table manually using
Here is an example with Rails 4.x.
Rails 5 allows to have UUID as column type in join table
Rails 5 has started supporting UUID as a column type for primary key, so
create_join_table should also support UUID as a column type instead of only integers.
Hence now Rails 5 allows us to use
UUID as a column type with create_join_table.
Here is revised example.