# Fields\_for weirdness

**URL:** <https://www.ruby-forum.com/t/fields-for-weirdness/177334>\
**Category:** Rails\
**Created:** [October 15, 2009, 6:14am UTC](https://www.ruby-forum.com/t/fields-for-weirdness/177334 "2009-10-15T06:14:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [October 15, 2009, 6:14am UTC](https://www.ruby-forum.com/t/fields-for-weirdness/177334/1 "2009-10-15T06:14:47Z")

</div>

I just did a large upgrade to to Rails 2.3.4 and I am trying to make  
use of the more modern view features.

I have a Newsletter object. Newsletter has many Sections.

I also have:

accepts\_nested\_attributes\_for :sections

on the Newsletter object.

I have the typical scaffolded new.html.erb with:

\<% form\_for(@newsletter) do |f| %\>

in there, I am trying to populate the first Section using fields\_for  
during the newsletter creation.  
If I try to emphasize “sections” in fields\_for , I get an exception.

Otherwise, I can do this:

\<% f.fields\_for :section, :index =\> 0 do |s| %\>

which in the forms creates newsletter[section][0].

It will recognize :section but not :sections.

If I manually set it so that it comes out as  
newsletter[sections][0]  
I get a “Section expected but got Array”

I have tried with and without the section index.

Any ideas? This is should be a text book usage and I am out of ideas  
to get it working.

thanks,  
C.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [October 15, 2009, 6:21am UTC](https://www.ruby-forum.com/t/fields-for-weirdness/177334/2 "2009-10-15T06:21:48Z")

</div>

of course… i post here and then I get it .

I started getting angry and thrashing and put the  
@newsletter.sections.build in the wrong method.  
once i moved it, everything started working just fine.

thanks,  
C.
