title: Iterate over an Active Record Relation in Rails 3.2
body: <p>I have the following code:</p>
  
  <pre><code>@items = QuestionGroup.search(params[:search]).limit(50)
  </code></pre>
  
  <p>This returns an ActiveRecord relation. In the view I want to iterate through it so I use:</p>
  
  <pre><code>&lt;% if @items.present? %&gt;
      &lt;%= @items.each do |r| %&gt;
          &lt;%= div_for r do %&gt;
              &lt;div&gt;&lt;%= r.subject %&gt;&lt;/div&gt;
          &lt;% end %&gt;
      &lt;% end %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>This does print r.subject to the view but it then follows it with the entire relation. e.g.</p>
  
  <pre><code>the pipe
  [#&lt;QuestionGroup id: **, subject: "the pipe", created_at: "*******", updated_at: "******"]
  </code></pre>
  
  <p>Why is this and how can I fix it?</p>