title: Ruby on Rails - Bullet/N+1
body: <p>On Rails 4. I recently installed the bullet gem for my development environment to clear up my app's N+1 queries. Relevant models:</p>
  
  <p><strong>Submissions</strong>: Belongs to Categories and Users. Has many SubmissionDetails.</p>
  
  <p><strong>Users:</strong> Has many Submissions</p>
  
  <p><strong>Categories:</strong> Has many Submissions. Belongs to Awards.</p>
  
  <p><strong>Awards:</strong> Has many Categories (and Submissions through Categories)</p>
  
  <p><strong>SubmissionDetails:</strong> Belongs to Submissions</p>
  
  <p>In my submission's index page, I have an <code>each do</code> statement to display each submission made by the current user.</p>
  
  <pre><code>&lt;% current_user.submissions.order('created_at DESC').in_groups_of(3, false) do |group| %&gt;
    &lt;div class="row"&gt;
      &lt;% group.each do |submission| %&gt;
  </code></pre>
  
  <p>After that, I list information about the submission, including its associated category, award, and submission details information. Bullet is saying I'm having N+1 issues with this statement:</p>
  
  <pre><code>N+1 Query detected Submission =&gt; [:category] Add to your finder: :include =&gt; [:category]
  N+1 Query detected Submission =&gt; [:user] Add to your finder: :include =&gt; [:user]
  N+1 Query detected Submission =&gt; [:submission_details] Add to your finder: :include =&gt; [:submission_details]
  </code></pre>
  
  <p>Every time I try to add <code>.includes</code> with all three of those models, it only picks the first one I list (this is not surprising). I figure I need to go a different route when multiple models are involved--perhaps a join statement?</p>
  
  <p>(When I make :category the first item, it adds this notice):</p>
  
  <pre><code>N+1 Query detected Category =&gt; [:award] Add to your finder: :include =&gt; [:award]
  </code></pre>
  
  <p>(So I also need to include as part of the statement a way to make Award fit in there as well, which, again, has many Submissions through Categories).</p>
  
  <p>So assuming I can't do one <code>.includes</code> for three different models, is there another way to go about this? Thanks.</p>