How do you set a custom id when using a check_box_tag helper in rails?
I have a loop which creates a bunch of checkboxes based on a collection:
- subject
@Ganesh, in your solution the resulting params hash has the following form:
params[:question][:syllabus_reference] = {1 => 1, 2 => 2, 3 => 3, ...}
These should work better for you:
check_box_tag "question[syllabus_reference][]", sr.id, checked, {:id => "question_syllabus_reference_#{sr.id}"
Notice the third parameter (checked) is required for this to work. The resulting params array will be
params[:question][:syllabus_reference] = {1, 2, 3, ...}