Forum: Ruby on Rails Sending multiple checkboxes values clicking a link

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0fc60326968a0eaccf30330fe6758375?d=identicon&s=25 Juan Kinunt (kinunt)
on 2009-03-07 19:45
Hi,
I have multiple checkboxes in a table each one representing an item.
They are like this:

[...]
<td><%= check_box "incidencias_ids", incidencia.id %></td>
<td><%=h incidencia.cliente.nombre %></td>
[...]

In the controller I have:

    incidencias_ids = params[:incidencias_ids]
    @incidencias = []
    for id in incidencias_ids
      @incidencias << Incidencia.find_by_id(id)
    end

I think this is enough to send all the checked checkboxes and manipulate
them.
But I don't know how to send all the checkboxes to the controller! I
know how to do it with link_to_remote but the answer is not displayed...

How I can do this with link_to? Another way?
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-03-07 20:24
(Received via mailing list)
On 7 Mar 2009, at 18:45, Juan Kinunt wrote:

>
> Hi,
> I have multiple checkboxes in a table each one representing an item.
> They are like this:
>
> [...]
> <td><%= check_box "incidencias_ids", incidencia.id %></td>
> <td><%=h incidencia.cliente.nombre %></td>
> [...]

Try check_box_tag "incidencias_ids[]", incidencia.id

There's more about why this works (ie what the [] are about) in the
guide on form helpers at guides.rubyonrails.org.

Fred
This topic is locked and can not be replied to.