I am upgrading an old Rails 1 application to Rails 2, and I’m running into a problem with the handling of check boxes. The old code has a check_box_tag call and corresponding hidden_field_tag call for each check box. While this worked before, after the upgrade all the checkboxes in the params hash come across as their default hidden value, regardless of whether they were checked. I’ve been reading about the check_box method, and how it has slowly changed from Rails 1 to 2 to 3 in terms of working with the corresponding hidden field.
Is there any documentation out there on how check box handling changed in Rails 2, or can someone explain why the Rails 1 approach no longer works?
Edit: After more research, I found this. It looks like in Rails 2.2 parameter extraction always gets the first occurrence of a given key (so the hidden field should go last), but in Rails 2.3 parameter extraction always get the last occurrence of a given key (so the hidden field should go first). And this apparently is poorly documented in the release notes and docs.
If I remember right, you don’t need to have an hidden field with rails 2, you just use check_box_tag and it does everything for you.