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.
8e7e5b934fcbcdfb475072685755457f?d=identicon&s=25 Taylor Strait (taylorstrait)
on 2009-01-10 23: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?
A91bd6cef23eb3516245a092e196c4da?d=identicon&s=25 Maurício Linhares (mauricio)
on 2009-01-10 23: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 Strait
8e7e5b934fcbcdfb475072685755457f?d=identicon&s=25 Taylor Strait (taylorstrait)
on 2009-01-12 23: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.