I have a partial to which i pass a collection. That views name is _row. So row.name, row.ssn gives me the details of each object in the collection, But i need to display 1. name 123456798 2. name1 234567890 how to get that Index ??? or count or whatever in that partial ?? please help.
on 2006-04-25 05:41
on 2006-04-25 05:54
On 4/24/06, prasanth satya <email@example.com> wrote: > how to get that Index ??? or count or whatever in that partial ?? > > please help. > render :partial => 'row', :collection => @some_collection ..will create a local variable 'row_counter' inside your partial. You can then do: <% @row = row -%> <%= text_field 'row', 'name', :index => row_counter %>
on 2006-04-25 05:58
you can obtain the current index from within the partial by using <partial_name>_counter. ie, if you called your partial via: render(:partial => 'books', :collection => @book_list) you could use books_counter to retrieve the current index. Mike
on 2006-04-25 06:32
Thank you very much... that worked.