Brian Donahue
2006-Mar-19 20:54 UTC
[Rails] Rendering Partials w/Collections - is there a way to find the position?
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 Reubenstein
2006-Mar-19 20:59 UTC
[Rails] Rendering Partials w/Collections - is there a way to find the position?
Hi Brian, You can find out the current index by calling: <%= message_counter %> In your partial. ~ Ben On 3/19/06, Brian Donahue <brian@pigeonmoon.com> wrote:> > 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? > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Ben Reubenstein http://www.benr75.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060319/1fd85667/attachment.html