title: RoR3 Model associations (Game belongs_to two Players)
body: <p>I'm <strong>really new</strong> to Ruby on Rails 3 and I'm working on a simple chess game application. I plan to create the following models:</p>
  
  <pre><code>rails g model Player name:string
  rails g model Game player_id_white:int player_id_black:int title:string
  rails g model Comment player_id:int game_id:int comment_data:text
  rails g model Move game_id:int player_id:int move_data:string
  </code></pre>
  
  <p>Assume they all have: id:int:primary_key, created_at:datetime, updated_at:datetime. I also omitted fields like 'password_hash' and others. My issue is with associations, not so much with what fields I need to make the app work.  </p>
  
  <pre><code>class Player &lt; ActiveRecord::Base
    has_many :games #some have player_id_black, others as player_id_white
    has_many :comments
    has_many :moves
  end
  
  class Game &lt; ActiveRecord::Base
    has_many :comments
    has_many: moves
    **belongs_to :player1??**
    **belongs_to :player2??**
  end
  
  class Comment &lt; ActiveRecord::Base
    belongs_to :player
    belongs_to :game
  end
  
  class Move &lt; ActiveRecord::Base
    belongs_to :player
    belongs_to :game
  end
  </code></pre>
  
  <p>Questions:  </p>
  
  <p>1) I want to link a Game to two Players, how can I specify that relationship?<br>
  2) Do I have to specify things like game_id:int in 'rails generate model' or is it implicit when I do the relationships (belongs_to :player, has_many :games)?</p>
  
  <p>Thanks!</p>