title: How do I interact with a collection in a helper but only return a specific output not the entire collection?
body: <p>In my view, I have this:</p>
  
  <pre><code>&lt;% node.tagged_users.each do |tagged_user| %&gt;
     &lt;li&gt;&lt;%= display_avatar_or_email(tagged_user) %&gt;&lt;/li&gt;
  &lt;% end -%&gt;
  </code></pre>
  
  <p>But, what I am trying to do is create a helper method that whenever there are say 5 <code>tagged_users</code>, it will show the avatars for the last 3, then show a link on the text "2 more" or "2+" (per the image below). Note, it shouldn't show the total users tagged, just the difference between the number of tagged users currently being shown as avatars and the total number of tagged users for this particular node.</p>
  
  <p>So it would look something like this:</p>
  
  <p><img src="https://i.stack.imgur.com/eJjAq.png" alt="enter image description here"></p>
  
  <p>Not sure if it matters, but the method for <code>display_avatar_or_email(tagged_user)</code> looks like this:</p>
  
  <pre><code>  def display_avatar_or_email(user)
      link_to image_tag(user.avatar.url, size: "48x48", :class =&gt; "img-circle", title: user_name_or_email(user)), user
    end
  </code></pre>
  
  <p>I have a method for the <code>tagged_users.count</code>:</p>
  
  <pre><code>  def total_tagged_users_count(node)
      node.user_tags.count
    end
  </code></pre>
  
  <p>When I moved the entire <code>node.tagged_users.each do |tagged_user|</code> into my helper, it spat out the entire AR collection in my view - which is not what I want. I just want the result of the logic, not everything within the method.</p>
  
  <p>What's the best way to do this in a helper, in a Rails-way?</p>