views:

16

answers:

1

Is it possible to create a join table without a model. I have a model called User and Pet. I want user to have only one pet and pet to only have one owner. Very simple. However, I am trying to figure out how to create a join table

pets_users that has both users.id and pets.id in it without having to create the actual model. Is this possible? Is this a bad design?

If possible, how do I create a new entry in the pets_users table?

+2  A: 

You don't need a join table for this.

User has_one Pet
Pet belongs_to User

The pet table then would have a user_id column and Active Record handles the rest for you.

Toby Hede