issue with check boxes

You know the helper for check boxes generates a hidden field with an "unchecked" value.

In a form with fields like this:

  <% fields_for "project[invoice_attributes]", invoice, :index => nil do |form| %>     <%= form.check_box :paid %>     ...

the parameters parser gets confused by the pair and puts the checked value in a hash by itself, see this XML dump:

   http://pastie.org/216415

thus, there's a spurious hash on the one hand, and the actual model hash gets the unchecked value unconditionally.

Looking at UrlEncodedPairParser#bind in request.rb, my understanding is that we switch to a new hash when we get a key that exists in the previous hash (top[-1]). Since at that point there's no knowledge about what's a check box or boolean model attribute I don't quite see how that could be addressed.

Ideas?

I can't think of a good server-side solution. One would somehow tell Rails to infer missing boolean attributes, but looks difficult to come with a proposal that is transparent and maintains backwards compatibility.

In the client-side the best I can think of is to observe_field the check box to insert/remove the hidden field as needed, but that would need Prototype or some weird inline handler. Falling back to the current behaviour if JavaScript is disabled. Ugh, doesn't sound right either.

By now I've documented the issue:

http://github.com/lifo/docrails/commit/ea40dc09a564ebc2b0034e3c1ae2c4daffe7e79b