我最近正在使用标签,经过一些实验,我决定调整一个标签来显示一个模型的一个或多个实例(联系人)。好吧,按照fields_for的步骤,在主体下面的tab-content下创建了一些选项卡窗格。逻辑是:
DadosBásicos| Endereço| Contatos
(联系方式1)(联系方式2)(联系方式3)......
导航丸后,应该显示各自的联系人,但它什么也没显示。路由有问题吗? (使用#contact -...等)
<div class="inner">
<ul class="nav nav-tabs">
<li class="active"><a href="#dados" data-toggle="tab">Dados Básicos</a> </li>
<li><a href="#adresses" data-toggle="tab">Endereço</a></li>
<li><a href="#contacts" data-toggle="tab">Contatos</a></li>
</ul>
...
<div class="tab-content">
<div class="tab-pane" id="contacts">
<ul class="nav nav-pills">
<% @customer.contacts.each_with_index do |co, i| %>
<% if i==0 %><li class="active"><% else %><li><% end %>
<a href="#contact-<%= i %>"><%= co.nome %></a></li>
<% end %>
</ul>
<div class="tab-content">
<%= f.fields_for :contacts do |k| %>
<div class="tab-pane" id="contact-<%= k.index %>">
<div class="well">
<%= k.hidden_field :id %>
<%= k.label :nome, "Nome" %>
<%= k.text_field :nome, class: 'form-control' %>
<%= k.label :setor, "Setor" %>
<%= k.text_field :setor, class: 'form-control' %>
<%= k.label :email, "Email" %>
<%= k.email_field :email, class: 'form-control' %>
<%= k.label :observacao, "Observação" %>
<%= k.text_area :observacao, class: 'form-control' %>
<%= k.fields_for :telephones do |tel| %>
<%= tel.hidden_field :id %>
<%= tel.label :telefone, "Telefone" %>
<%= tel.text_field :telefone, class: 'form-control' %>
<% end %>
</div>
<%= f.submit "Salvar Alterações", class: "btn btn-primary" %>
</div>
<% end %>
</div>
...