Hey I am using the following tables. My table course_enrollments references the user_id and the course_id. Both columns combined are set unique.
users
course_enrollments
courses
Rails sets primary keys by default. I have read some articles of people who used these kind of join tables without any pk. e.g. by defining :id => false
Is it appropriate for this kind of join table? what about people enrolling or leaving courses or the search for enrollments. Thanks for your time!
You generally see
:id => falseon the migration for your join table when you want to usehas_and_belongs_to_many, since Rails really doesn’t like finding an:idprimary key on these.From the
has_and_belongs_to_manydocs