title: in_groups_of(3) but only for the first 3 groups
body: <p>Expanding on <a href="https://stackoverflow.com/questions/14528919/new-row-every-3-items">New row every 3 items</a> -- I'm trying to insert ads in between my Forem (<a href="https://github.com/radar/forem" rel="nofollow noreferrer">https://github.com/radar/forem</a>) topics -- one in between every 3 topics for the first 3 groups of topics (3 ads in total).</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I ended up with this thanks to the answer below, unfortunately it doesn't seem to pass on <code>test</code> as a valid local (can't find <code>topic</code> inside <code>forem/topics/topic</code>):</p>
  
  <pre><code>&lt;% @topics.in_groups_of(3).each_with_index do |grouped_topics, index| %&gt;
    &lt;%= render partial: "forem/topics/topic", collection: grouped_topics %&gt;
    &lt;% if index &lt; 3 %&gt;
      &lt;p&gt;Ad&lt;/p&gt;
    &lt;% end %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p><strong>Live test app</strong> (click the big green <code>Run</code> button to test):</p>
  
  <p><a href="http://runnable.com/VFUNK2ho3Fpr8Fp2/forem-with-ads-in-between-topics" rel="nofollow noreferrer">http://runnable.com/VFUNK2ho3Fpr8Fp2/forem-with-ads-in-between-topics</a></p>
  
  <p>File in question: <a href="https://github.com/radar/forem/blob/rails4/app/views/forem/forums/show.html.erb" rel="nofollow noreferrer"><code>views/forem/forums/show.html.erb</code></a></p>