0
votes

I'm working on a job board app and I want a user to be able to star a job to be reviewed later in their profile page. I'm not sure where to begin with this when it comes to a HABTM relation. Right now I have a Job and User model. I would like a 'StarredJobs' joins table to have the user_id and job_id.

Do I create a separate model for the new 'StarredJobs' and add a HABTM relationship to Job and User? Or do I create the HABTM relationship to the 'StarredJobs' joins tables in each Job and User model?

1

1 Answers

0
votes

No, you don't have to create a third model for HABTM relationships. If you have the proper database set up such as below and you use the cake bake feature, it should bake the necessary relationships.

users: id, name, etc jobs: id, name, etc users_jobs: user_id, job_id

It should create a HABTM relationship in your models for you.