has-and-belongs-to-many Questions

2

Solved

In my rails app I have two models that are related by has_and_belongs_to_many. This means there is a join table. Imagine the scenario where I am adding users to a game. If I want to add a user, I ...
Klockau asked 9/11, 2009 at 22:46

1

Solved

I have a user model with a HABTM relationship to groups. I do not want a user to be able to be in more than 5 groups, so would like to validate the length of the HABTM relationship. On the edit us...

1

Solved

I have the following two models: School and User, and a HABTM relationship between them, with a join table. In this join table, the foreign key refering to the User table is not called user_id bu...

1

Solved

General Confusion I have bands which can have 3 genres. I read in a previous SO post that the proper way to handle this is a couple steps: 1) In band.rb has_and_belongs_to_many :genres 2) Creat...
Ephesians asked 12/6, 2009 at 1:3

1

Solved

In Rails you can use nested routes to create RESTful routes for has_one and has_many relationships. Examples can be found on the Rails Guides I'd like to ask if there is a good way to configure RE...
Provence asked 22/1, 2009 at 13:16

1

Solved

In my Rails app I have three models, Projects, BlogPosts and Images. Projects and BlogPosts can have many linked images and an image can be linked to a Project, a BlogPost or both. What is the bes...
Microsome asked 2/11, 2008 at 23:46

3

Solved

I have a situation where I have two models, companies and permissions, where companies is in a separate database from my permissions database. This is a has and belongs to many relationship because...
Penta asked 8/10, 2008 at 20:3

© 2022 - 2024 — McMap. All rights reserved.