한 필드가 아닌 두 필드 추가
                                            
                                                
                                                
                                                
                                                
                                                
                                                 4698 단어  nested_form
                    
묘사
헤이, 나는 이 초고에 끼워 넣는 형식을 사용한다.문제는 표에 한 필드를 추가할 때 한 번에 두 필드를 추가하는 것이다. 개발 환경에서만 생산이 정상적으로 작동할 수 있다.사람들이 무엇을 썼는지는 사례에 두 개의 자바스크립트 플러그인 폼이 추가되어 checked만 추가되었기 때문일 것이다.질문 또 있어요?나는 너의 응용 프로그램에 rails 자산 파이프가 있다고 추측한다.생성된 html과 포함된 자바 스크립트를 검사하고 개발 환경에서 프로그램을 실행할 때
토론 #1
가 비어 있는지 확인하십시오.개발 서버의public/assets 디렉터리토론 #2
가 비어 있습니다.<% content_for :javascripts do %>
  <%= javascript_include_tag 'routes' %>
<% end %>
<%= nested_form_for(@route) do |f| %>
    <div class="tabbable">
      <ul class="nav nav-tabs">
        <li class="active"><a href="#tab1" data-toggle="tab"><%= t(:route)%></a></li>
        <li><a href="#tab2" data-toggle="tab"><%= t(:route_points)%></a></li>
      </ul>
      <div class="tab-content">
        <div class="tab-pane active" id="tab1">
            <% if @route.errors.any? %>
                <div class="alert alert-error">
                    <button type="button" class="close" data-dismiss="alert">×</button>
                  <h4><%=t('errors.title')%></h4>
                  <ul>
                  <% @route.errors.full_messages.each do |msg| %>
                    <li><%= msg %></li>
                  <% end %>
                  </ul>
                </div>
              <% end %>
              <div class="field">
                <%= f.label :date, t(:date) %>
                <%= f.text_field :date, id: 'date_gt'%>
              </div>
              <div class="field">
                <%= f.label :manager, t(:manager) %>
                <%= f.select(:manager_id, @managers.collect  {|p| [ p.name, p.id ]}, :include_blank => t(:select_manager)) %>
              </div>
        </div>  
            <div class="tab-pane" id="tab2">
                <table id="table" class="table table-striped table-hover">
                    <thead>
                        <tr>
                            <th><%= t(:shipping_address)%></th>
                            <th><%= t(:status)%></th>
                            <th><%= t(:actions) %></th>
                        </tr>
                    </thead>
                    <tbody>
                        <%= f.fields_for :route_points, :wrapper => false do |route_point| %>
                            <tr class="fields">
                                <td><%= route_point.select :shipping_address_id , @shipping_addresses.collect  {|p| [ p.name, p.id ] }, {:include_blank => t(:select_shipping_address)} %></td>
                                <td><%= route_point.select :status_id , @statuses.collect  {|p| [ p.name, p.id ] }, {:include_blank => t(:select_status)} %></td>
                                <td><%= route_point.link_to_remove do %><i class='icon-remove' title="<%= t(:remove)%>"></i><% end %></td>
                            </tr>   
                        <% end %>
                    </tbody>
                </table>
                <p><%= f.link_to_add t(:add), :route_points, :class =>'btn', :data => { :target => "#table" } %></p>    
            </div>
            <div class="actions">
            <%= f.submit(t(:save), :class =>'btn') %>
          </div>
        </div>
    </div>
<% end %>
public/assets만 불러왔습니다. 문제는 무엇입니까?토론 #셋
토론 #4
복제 오류의 예시 프로그램을 제공할 수 있습니까?토론 #5
문제는 자바 스크립트의 이중 추가입니다. 문제는 계속되고 있습니다.고마워토론 #6
어떻게 해결했어?토론 #7
이 문제는 아주 오래된 일인데, 지금은 기억이 안 나요.나는 마침내 밑단을 없애고 helper accepts 끼워 넣은 속성을 사용했다.Reference
이 문제에 관하여(한 필드가 아닌 두 필드 추가), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://github.com/ryanb/nested_form/issues/256텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)