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:

<div><%=error_messages_for :book-%></div>
<%form_remote_for :book,@book,:update=>"[email protected]}",:url=>books_path
do|v|%>
     <table>
       <tr>
         <td><%=v.label "name"-%></td>
         <td><%=v.text_field :name-%></td>
       </tr>
     </table>
      <div id="pages">
       <%=render :partial=>'page',:collection=>@book.pages-%>
      </div>
     <%=submit_tag 'create'-%>
<%end-%>

page partial
<%fields_for "book[new_pages][]",page do|o|-%>
    <table>
      <tr>
        <td><%=o.label "name"%></td>
        <td><%=o.text_field :name%></td>
        <td><%=o.label "color"%></td>
        <td><%=o.text_field :color%></td>
      </tr>
    </table>
<%end-%>

"book"=>{"new_pages"=>[{"name"=>""}, {"name"=>"", "color"=>""},
{"color"=>""}]...
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to