나는 PHP 응용 프로그램을 레일에 이식하고 있으며 복잡한 양식에 문제가 있습니다. menu_headers라는 acts_as_tree 모델을 가지고 있으며, 단일 페이지에서 메뉴를 편집 할 수있는 양식을 만들고 싶습니다. 메뉴에는 무제한의 menu_headers가있을 수 있습니다.Rails 3.1 acts_as_tree, 한 페이지의 메뉴를 편집하기위한 양식 및 값
나는 edit.html.erb에있다 :이
#this text field works
<%=text_field :menu_header, :name, :index=>@menu_header.id %>
<% if @menu_header.children.empty? %>
<div>no submenus</div>
<% else %>
<ul>
<%= render :partial => 'menu_header_form', :collection => @menu_header.children %>
</ul>
<% end %>
작동하고 _menu_header_form.html.erb의 이름은 menu_header [3] [이름]으로 올바른이다하지만 값이 잘못되었습니다 - 이전 절의 이름 값입니다. 문제는 입력 태그의 이름을 값에서 어떻게 분리 할 수 있습니까? 아마도 옵션을 통해?
# this is text field is problematic one; want to get menu_header_form.name into the
# value attribute of the tag
<%=text_field "menu_header", :name, :index=>menu_header_form.id %>
<% if menu_header_form.children.empty? %>
<div>no submenus</div>
<% else %>
<ul><%= render :partial => 'menu_header_form', :collection => menu_header_form.children %>
there are submenus
</ul>
<% end %>
위의 text_field에 올바른 값을 지정하는 방법은 무엇입니까?
들으