我有一个非常不守规矩的观点。我想将更多的视图转移到其他部分,但这会导致嵌套的部分...我很担心。我已经听说过演示者模式,并希望在这里实现它,但我不知道如何去做。特别是我的行包含一个do循环,我认为我不能轻易提取。非常感谢任何建议!
<div class="row">
<h2>Applicant</h2>
<%= render partial: 'people/summary', locals: { person: @applicant.identity } %>
<%= link_to "Edit", edit_person_path(@applicant.identity), class: "btn btn-info"%>
</div>
<%= render partial: 'divrow', locals: { var1: "Household members" } %>
<%= render partial: 'structure', locals: { path: "new_household_member_path" } %>
<div class="row">
<h2>Residence history</h2>
<% @applicant.residences.each do |r| %>
<div class="col-md-4">
<p>
<%= render partial: 'residences/summary', locals: { residence: r } %>
<%= link_to "Edit", edit_residence_path(r), class: "btn btn-info"%>
<%= link_to 'Delete', r, method: :delete, class: "btn btn-danger", data: { confirm: 'Are you sure?' } %>
</p>
</div>
<% end %>
</div>
<%= render partial: 'structure', locals: { path: "new_residence_path" } %>
<div class="row">
<h2>Income</h2>
<% @applicant.incomes.each do |i| %>
<p>
<%= render partial: "incomes/summary", locals: { income: i } %>
<%= link_to "Edit", edit_income_path(i), class: "btn btn-info"%>
<%= link_to 'Delete', i, method: :delete, class: "btn btn-danger", data: { confirm: 'Are you sure?' } %>
</p>
<% end %>
</div>
<%= render partial: 'structure', locals: { path: "new_income_path" } %>
<div class="row">
<h2>Employment</h2>
<% @applicant.employments.each do |e| %>
<div class="col-md-4">
<p>
<%= render partial: "employments/summary", locals: { employment: e } %>
<%= link_to "Edit", edit_employment_path(e), class: "btn btn-info"%>
<%= link_to 'Delete', e, method: :delete, class: "btn btn-danger", data: { confirm: 'Are you sure?' } %>
</p>
</div>
<% end %>
</div>
<%= render partial: 'structure', locals: { path: "new_employment_path" } %>
<div class="row">
<h2>Criminal history</h2>
<% @applicant.criminal_histories.each do |e| %>
<div class="col-md-4">
<p>
<%= render partial: "criminal_histories/summary", locals: { criminal_history: e } %>
<%= link_to "Edit", edit_criminal_history_path(e), class: "btn btn-info"%>
<%= link_to 'Delete', e, method: :delete, class: "btn btn-danger", data: { confirm: 'Are you sure?' } %>
</p>
</div>
<% end %>
</div>
<%= render partial: 'structure', locals: { path: "new_criminal_history_path" } %>