Checkboxes

Hi,

I’ve got a form like so:

<% @companies.each do |company| %>
<%= company.name %>


<% end %>

which posts eg. this hash:
Parameters: {“commit”=>“Dispatch”, “companies”=>[“36”, “29”, “31”,
“34”]}

to this action:

def dispatch
if params[:companies]
params[:companies].each do |key, value|
@company = Company.find(value)
@companies << @company
end
end

I get the error message “Couldn’t find Company without an ID”

help!

Thanks in advance

Adam

I think params[:companies] is an Array, not a Hash, so .each won’t pass
you the key, just the value. So you need something like:

params[:companies].each do |value|

Hope this helps

Jeff
www.softiesonrails.com