Rails Foreign key setup question.

Posted by James P. Wright on Stack Overflow See other posts from Stack Overflow or by James P. Wright
Published on 2011-06-21T19:59:14Z Indexed on 2011/06/22 0:23 UTC
Read the original article Hit count: 474

I'm just (re)starting playing around with Rails and I'm making a little card game app. I cannot seem to figure out my Foreign Key setups.
Say I have 4 objects:
- Game
- Player
- Hand
- Card

A Game has many Players, which have many Hands which have many Cards. But the cards are also independent of a Hand, Player and Game.
For example, I have 6 Cards in my database (1 to 6). It is possible that Card 3 could be in 2 Players Hands in the same Game.

How can I set up my keys for this? Should I just create another object for "CardInHand" to simplify it?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby