fields_for: how many objects can it handle - max string size?

Our app is getting a "string sizes too big" error in an .erb file that is trying to render a large block of checkboxes that represent color attributes that belong_to the product being edited in this view. The code worked fine when we had a small number of colors -- now that the number of colors is 750+, we get an error on the fields_for line (see below).

Since this sounds somewhat like some older memory leak issues, I confirmed that our host, Engine Yard, does not have an old Ruby version (they are on 1.8.6 patch level 287). The same error occurs on Mac OS/X with Ruby 1.8.6 patch 369.

I've had no luck searching for that error with "fields_for" or finding any docs on size limitations inherent to fields_for.

Processing Admin::ProductsController#edit (for 173.45.210.193 at 2010-04-29 05:21:30) [GET]   Parameters: {"id"=>"17"} Rendering template within admin/layouts/base Rendering admin/products/edit

ActionView::TemplateError (string sizes too big) on line #67 of app/ views/admin/products/edit.html.erb: 64: 65: <div id="colorCheckboxes"> <!-- event handler searches within this div to find checkboxes --> 66: <% previousObject = nil -%> 67: <% f.fields_for :prod_method_colors do |pmc| -%> 68: <% pmcObj = pmc.object %> 69: <%= "<br/><br/> Colors for #{PRINT_METHOD_TEXT[pmcObj.print_method]} <br/>" if previousObject == nil || (pmcObj.print_method != previousObject.print_method) %> 70: <% previousObject = pmcObj -%>

There's only one place in the ruby C code I could find that raises 'string sizes too big'. It's raised in a string concatenation function if the length of the existing string plus the length of what you're concatenating exceeds LONG_MAX, ie 2^31-1 on a 32bit system. I'm not sure why fields for would be attempting to concatenate two strings with a combined length of 2GB.

Fred