writing multiple checkbox values

Is it possible to write multiple checkbox values? When i click on submit, the first value "accounting_services" is written to the database, but all of the others are ignored.
I created a column in my registration database table with a title of organizationservices, and type of string.

<td><%= f.check_box(:organizationservices, {:class => 'check_box'},"accounting_services","") %>Accounting/Auditing Services
</td>
<td><%= f.check_box(:organizationservices, {:class => 'check_box'},"Actuarial_Services","") %>Actuarial Services
</td>
<td><%= f.check_box(:organizationservices, {:class => 'check_box'},"com_dev","") %>Alternative/Comm. Dev. Investments
</td>
<td> <%= f.check_box(:organizationservices, {:class => 'check_box'},"test 1","not test 1") %>Test</td>

thank you,
Jason

There is a browser limitation on checkboxes.
At least for some browsers, the checkbox value is only sent,
if the checkbox is checked. for unchecked boxes nothing is
returned.
So you must check against params[:model_name][:checkbox_name].nil?
or something like that.

Jason White wrote:

Is it possible to write multiple checkbox values? When i click on
submit, the first value "accounting_services" is written to the
database, but all of the others are ignored.
I created a column in my registration database table with a title of
organizationservices, and type of string.

<td><%= f.check_box(:organizationservices, {:class =>
'check_box'},"accounting_services","") %>Accounting/Auditing Services
</td>
<td><%= f.check_box(:organizationservices, {:class =>
'check_box'},"Actuarial_Services","") %>Actuarial Services
</td>
<td><%= f.check_box(:organizationservices, {:class =>
'check_box'},"com_dev","") %>Alternative/Comm. Dev. Investments
</td>
<td> <%= f.check_box(:organizationservices, {:class =>
'check_box'},"test 1","not test 1") %>Test</td>

thank you,
Jason

Hi there,
so,
the html you want to generate is;

<input type="checkbox" name="organisation[organisationsservices][]"
value="abc" />

this will create an array in the params

:organisation => {:organisationservices => ["abc"]}

with all the checked values being put in there.

but, I dont think you can do this with the :form_for syntax.

so, instead

  <td><%= check_box_tag("organisation[organisationservices][]",
"accounting_services",
@organisation.accounting_services.include?("accounting_services"))
%>Accounting/Auditing Services
  </td>

....

I suggest you wrap this into a helper if you need to use it a lot..

Matthew Rudy
http://www.workingwithrails.com/person/12394-matthew-rudy-jacobs