I have found the solution by setting :multiple => true
, which will give the right result.
<%= f.hidden_field :location, :multiple => true, :id => "foo_location_1" %>
<%= f.hidden_field :location, :multiple => true, :id => "foo_location_2" %>
solved Rails how to render array field in template use form_builder?