Topic: Editing child fields lost on upgrade to rails 3.2.2 [SOLVED]

Recently I upgraded from rails 3.0.7 to rails 3.2.2

Now my form, which uses accepts_nested_attributes_for to edit multiple child records, no longer works.

In my models I use belongs_to, has_many and accepts_nested_attributes_for to set up the parent-child relationships.

In my form I use form_for initially, then fields_for to generate the child fields in the form:

<%= form_for(@tc_employee) do |f| %>
.... stuff here ...., then I use a loop to create a set of text boxes for each child record:

<% i = 0 %>
<div class="child">
  <% f.fields_for :TcDatum do |pf| %>
    <div>
    <%= pf.hidden_field :d1 %>
    ... more hidden fields here .... then:
    <%= pf.text_field :total_hours, :size => 4, :onclick => blah blah ... %>
    <%= pf.label :total_hours, pf.object.label_text, :style .... %>
    <% i = i + 1 %>
    </div>
  <% end %>
</div>
....etc to the end of the form..

For some reason, none of the fields in the fields_for section are generated, neither the hidden fields nor the total_hours field or it's label.  They are created in the rails 3.0.7 installation but not on the server upgraded to rails 3.2.2.

Any ideas how to get my fields_for child fields back?

Thanks for any help. --Fred

p.s. do the site managers know that half the time I submit a question, using 'preview' first, a lot of the text of my post is lost?

Last edited by fredrated (2012-05-31 12:36:45)

Re: Editing child fields lost on upgrade to rails 3.2.2 [SOLVED]

One thing I should add: when I first created the app in rails 3.0.7, I created my custom form by copying _form.html.erb (created by the rails generator) and then added my code to create timecard.html.erb.  For the upgraded version of rails (3.2.2) I simply copied timecard.html.erb from the directory of the old rails into the directory of the new rails app.  If the new rails generator adds anything special (I will look in the files to see) to _form.html.erb, then that will clearly be missing from timecard.html.erb.
--Fred

Re: Editing child fields lost on upgrade to rails 3.2.2 [SOLVED]

The answer is in the following code:
<% f.fields_for :TcDatum do |pf| %>

In rails 3.0.7 this works fine.
In rails 3.2.2 (and 3.2.3 as well) this code needs the equals sign (=) as in:
<%= f.fields_for :TcDatum do |pf| %>

Without the '=', no display; with it the html displays properly.
So, even though this single line does not insert html, the block it controls does, so now the '=' is required by the ruby interpreter.