Fields_for can not group its params when ajax

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

but it is
“book”=>{“new_pages”=>[{“name”=>""}, {“name”=>"", “color”=>""},

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

new_book page:

<%=error_messages_for :book-%>
<%form_remote_for :book,@book,:update=>"book{}",: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%>


“book”=>{“new_pages”=>[{“name”=>""}, {“name”=>"", “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