title: Ruby HABTM association loop
body: <p>i want to achieve a nested loop without duplicates in a have and belongs to many relationship</p>
  <p>i have a model 'campaign' and for each campaign i also have campaign data.</p>
  <p>i want to display each campaign with its campaign data in a table. (nested)</p>
  <pre><code>@campaigns = current_user.campaigns
   &lt;% @campaigns.each do |item| %&gt;
            &lt;% i = item.campaign_data %&gt;
              &lt;% i.each do |cdata| %&gt;
              &lt;%= cdata.date %&gt;
              &lt;tr&gt;
                &lt;td&gt;
                &lt;%= item.name %&gt;
                &lt;/td&gt;
                &lt;td&gt;
                &lt;%= cdata.date %&gt;
                &lt;/td&gt;
                &lt;td&gt;
                &lt;/td&gt;
              &lt;/tr&gt;
            &lt;% end %&gt;
            &lt;% end %&gt;
  </code></pre>
  <p>my problem is that my campaigns get duplicated.</p>
  <p>I want to achieve something like this:</p>
  <p>Each campaign is listed in the table with its corresponding campaign_data directly below it, and if no campaign_data is left the next loop begins with the next campaign - is this possible?</p>
  <p>best regard</p>