# Fields\_for can not group its params when ajax

**URL:** <https://www.ruby-forum.com/t/fields-for-can-not-group-its-params-when-ajax/192535>\
**Category:** Rails\
**Created:** [August 1, 2010, 1:15pm UTC](https://www.ruby-forum.com/t/fields-for-can-not-group-its-params-when-ajax/192535 "2010-08-01T13:15:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hong107yan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a8b319/32.png) [@hong107yan](https://www.ruby-forum.com/u/hong107yan)\
**Post date:** [August 1, 2010, 1:15pm UTC](https://www.ruby-forum.com/t/fields-for-can-not-group-its-params-when-ajax/192535/1 "2010-08-01T13:15:51Z")

</div>

hi  
book and page is one\_to\_many relationship.I want to create them in a  
single form.But when clicking create button,the submitted params for  
pages are not grouped correctly,  
i want  
“book”=\>{“new\_pages”=\>[{“name”=\>"", “color”=\>""},  
{“name”=\>"",“color”=\>""}]

but it is  
“book”=\>{“new\_pages”=\>[{“name”=\>""}, {“name”=\>"", “color”=\>""},  
{“color”=\>""}]\

My page and params are listed below.please help me,this take me a whole  
day.

new\_book page:

\<%=error\_messages\_for :book-%\>
\<%form\_remote\_for :book,@book,:update=\>"book{@book.id}",:url=\>books\_path do|v|%\> 

| \<%=v.label "name"-%\> | \<%=v.text\_field :name-%\> |

 \<%=render :partial=\>'page',:collection=\>@book.pages-%\> 
 \<%=submit\_tag 'create'-%\> \<%end-%\>

page partial  
\<%fields\_for “book[new\_pages][]”,page do|o|-%\>

  
  
  
  
  
  
  

| \<%=o.label “name”%\> | \<%=o.text\_field :name%\> | \<%=o.label “color”%\> | \<%=o.text\_field :color%\> |

  
\<%end-%\>

“book”=\>{“new\_pages”=\>[{“name”=\>""}, {“name”=\>"", “color”=\>""},  
{“color”=\>""}]…
