checkboxes in a loop - I get the same id

<% f.fields_for :keys do |key_form| %>
    <%= check_box_tag "keys_to_update[]", key_form.object.id %>
    <%= key_form.label :name, key_form.object.name %>
<% end %>

This is the output:

<input id="keys_to_update_" name="keys_to_update[]" type="checkbox"
value="4" />
<input id="keys_to_update_" name="keys_to_update[]" type="checkbox"
value="5" />

I try to use cucumber and check only one of them (or all of them) but
need an id.

Thanks!

what about key_form.id?

This is the output:

<input id="keys_to_update_" name="keys_to_update[]" type="checkbox"
value="4" />
<input id="keys_to_update_" name="keys_to_update[]" type="checkbox"
value="5" />

I try to use cucumber and check only one of them (or all of them) but
need an id.

You can override the automatically generated id with anything of your
choice (the last argument to check_box_tag is a hash of html options

Fred

works, thank you!