Fields_for can not group its params when ajax

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”=>""}]…

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs