Forum: Ruby on Rails hidden_field_tag flattens my array for value

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Taylor S. (Guest)
on 2009-01-11 00:35
<%= hidden_field_tag('users_ids', @users.collect(&:id))%>

  <input id="users_ids" name="users_ids" type="hidden"

I want to grab an array of user ids and then do something with them, but
hidden_form_tag is flattening my array.  I've tried various ways of
putting an array into h_f_t and it always flattens it.  How can I
preserve the structure of my array?
Maurício L. (Guest)
on 2009-01-11 00:49
(Received via mailing list)
Try this:

<% for user in @users %>
    <%= hidden_field_tag "user_id[]", %>
<% end %>

Maurício Linhares (pt-br) |

On Sat, Jan 10, 2009 at 8:35 PM, Taylor S.
Taylor S. (Guest)
on 2009-01-13 00:53
Maurício Linhares wrote:
> Try this:
> <% for user in @users %>
>     <%= hidden_field_tag "user_id[]", %>
> <% end %>

This worked perfectly.  Thank you.
This topic is locked and can not be replied to.