title: Join two tables with condition - ruby on rails
body: <p>I wanna join 2 table, games and game_logs. I did it this:</p>
  
  <pre><code>game_joins =  Game.joins(:game_logs)
  </code></pre>
  
  <p>It worked. But the thing is I only want to join where the player_id = 1(for example). Column player_id can only be found in table game_logs. So, when I do like this:</p>
  
  <pre><code>game_joins =  Game.joins(:game_logs).where(:player_id =&gt; 1)
  </code></pre>
  
  <p>Column player_id can't be found, because </p>
  
  <pre><code>Game.joins(:game_logs)  
  </code></pre>
  
  <p>will result :</p>
  
  <pre><code>SELECT games.* FROM games
    INNER JOIN game_logs ON game_logs.game_id= game.id
  </code></pre>
  
  <p>So, the question is what is the possibility I have to filter game_joins with the condition from table game_logs. I hope I explain it well enough. Thanks </p>