Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3787980
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T11:55:35+00:00 2026-05-19T11:55:35+00:00

Hey I am using the following tables. My table course_enrollments references the user_id and

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T11:55:36+00:00Added an answer on May 19, 2026 at 11:55 am

    You generally see :id => false on the migration for your join table when you want to use has_and_belongs_to_many, since Rails really doesn’t like finding an :id primary key on these.

    From the has_and_belongs_to_many docs

    The join table should not have a
    primary key or a model associated with
    it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey I am using Jquery draggable droppable with table I have initialize both and
Hey all. I've got the following set of tables which is variable and adds
Hey I am currently using the following code Dim flickr As New Flickr(apikey) Dim
Hey everyone. The following is the code that I am using to play random
Hey everyone, I have achieved the effect described in the title using the following
Hey I have the following code which I'm using to isolate the a b
Hey everyone, I need to convert the following format into a new format using
Hey guys..I am designing a set-up wizard using CPropertySheet and CpropertyPage in MFC application...I
Hey guys, I'm writing a Firefox plugin and using the following function: var obj
hey guys, m using an api of Bits on the Run following is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.