Forum: Ruby on Rails Rendering Partials w/Collections - is there a way to find th

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Brian D. (Guest)
on 2006-03-19 22:54
(Received via mailing list)
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?
Ben R. (Guest)
on 2006-03-19 22:59
(Received via mailing list)
Hi Brian,

You can find out the current index by calling:

<%= message_counter %>

In your partial.

~ Ben
This topic is locked and can not be replied to.