title: Rails Activerecord multiple table includes
body: <p>I have four tables:</p>
  
  <p><strong>argument</strong> with fields</p>
  
  <ul>
  <li>id</li>
  </ul>
  
  <p><strong>comments</strong> with</p>
  
  <ul>
  <li>id</li>
  <li>comment_id</li>
  <li>argument_id</li>
  <li>user_id</li>
  </ul>
  
  <p><strong>users</strong></p>
  
  <ul>
  <li>id</li>
  </ul>
  
  <p><strong>nicknames</strong> with</p>
  
  <ul>
  <li>id</li>
  <li>proposal_id</li>
  <li>user_id</li>
  <li>name</li>
  </ul>
  
  <p>each argument has many comments, </p>
  
  <p>each comment belongs to a user, </p>
  
  <p>each user has a specific nickname in the argument. </p>
  
  <p>When I fetch the argument comments from DB, I would like to include also the nicknames of each author.</p>
  
  <p>The answer is about the <strong>ActiveRecord query I don't know how to write</strong>.</p>
  
  <p>I tried with</p>
  
  <pre><code>@argument.comments.includes(:user =&gt; :nicknames)
  </code></pre>
  
  <p>but it doesn't seems to work and when I get the nickname through
      nickname = @argument.nicknames.find_by_user_id(comment.user.id)
  it executes the query...</p>
  
  <pre><code>[1m[36mNickname Load (0.6ms)[0m  [1mSELECT "nicknames".* FROM "nicknames" WHERE "nicknames"."argument_id" = 59 AND "nicknames"."user_id" = 9 LIMIT 1[0m
  </code></pre>
  
  <p>any suggestion?</p>