Check BOX problem

Use "[]"'s to send it in the params as a hash like this:

<% @users.each do |user| -%>
    <%= check_box(:user, :id, :name => "user[#{}]" -%>
<% end -%>

When this is sent back to the controller, you will have params[:user] as a hash with user id's as the keys and 1 as the value.

Sandeep Gudibanda wrote:

2 things I forgot to mention. First, the method passed to check_box
(:id in the below example) is evaluated as an integer and any non-zero
value will check the box. Second, if you use an instance variable named
the same and the name of the checkbox, you can clean things up a bit
like this

<% for @user in @users -%>

<%= check_box "user[]", :access_allowed? -%>

<% end -%>

This will achieve the same thing. This example assumes there is a
method for users that denotes whether they have access or not (and
whether to check the box or not). I’m just playing off your example.

William Pratt wrote: