How to get index in partial with fields_for by nested records

Given:

<%= f.fields_for :socials do |builder| %> <%= render :partial => "social_fields", :locals => { :f => builder} %> <% end %> 

how can I get the counter / index inside the counter _social_fields.html.erb (for something on the last element)? social_fields_counter seems to be generated only if you explicitly pass: collection to render, but these are nested objects with accepts_nested_attributes_for: socials in the parent.

+4
source share
1 answer

Inside _social_fields.html.erb :

 <%= f.options[:child_index] %> 
+13
source

All Articles