# Rendering Partials w/Collections - is there a way to find th

**URL:** <https://www.ruby-forum.com/t/rendering-partials-w-collections-is-there-a-way-to-find-th/55333>\
**Category:** Rails\
**Created:** [March 19, 2006, 9:54pm UTC](https://www.ruby-forum.com/t/rendering-partials-w-collections-is-there-a-way-to-find-th/55333 "2006-03-19T21:54:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![madscene](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/5f9b8f/32.png) [@madscene](https://www.ruby-forum.com/u/madscene)\
**Post date:** [March 19, 2006, 9:54pm UTC](https://www.ruby-forum.com/t/rendering-partials-w-collections-is-there-a-way-to-find-th/55333/1 "2006-03-19T21:54:47Z")

</div>

This seems obvious, but I wasn’t able to find info on it easily. If  
you are rendering a partial from a collection:  
\<%= render :partial =\> ‘message’, :collection =\> @messages %\>

Is there a way inside the partial to tell what item in the collection  
you are on? For example, if I am in the first element in the  
collection, I want to do something different?

---

<div class="post-metadata">

**Author:** ![madscene](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/5f9b8f/32.png) [@madscene](https://www.ruby-forum.com/u/madscene)\
**Post date:** [March 19, 2006, 9:59pm UTC](https://www.ruby-forum.com/t/rendering-partials-w-collections-is-there-a-way-to-find-th/55333/2 "2006-03-19T21:59:08Z")

</div>

Hi Brian,

You can find out the current index by calling:

\<%= message\_counter %\>

In your partial.

~ Ben
