Basically I want it to produce something like this:
<input name="addresses[][line1]" type="text"/>
<input name="addresses[][line2]" type="text"/>
<input name="addresses[][city]" type="text"/>
And then expect params[:addresses] to be an array.
I used fields_for
with index, but that produces a hash upon submission, e.g.:
<%= f.fields_for :addresses, index: 1 do |builder| %>
<%= render 'addresses', f: builder %>
<% end %>
# =>
<input name="addresses[1][line1]" type="text"/>
<input name="addresses[1][line2]" type="text"/>
<input name="addresses[1][city]" type="text"/>
I also tried few examples from Action View Form Helpers — Ruby on Rails Guides but it didn’t worked for some reason… Any idea how to omit the index value while keep the square brackets? (rails 4.0.2 here)
Thanks in advance.