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.
C79b0fa6c468a7f9b3cd1874c0012c74?d=identicon&s=25 Brian Donahue (Guest)
on 2006-03-19 21: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?
D90ef6808433e63203e15a5c2dadb0bb?d=identicon&s=25 Ben Reubenstein (Guest)
on 2006-03-19 21: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.