<commit_before><%
parent_record = @record
associated = column.singular_association? ? [parent_record.send(column.name)].compact : parent_record.send(column.name)
associated = associated.sort_by {|r| r.new_record? ? 99999999999 : r.id} unless column.association.options.has_key?(:order)

show_blank_record = (column.plural_association? or (column.singular_association? and associated.empty?))
show_blank_record = false if column.through_association?
show_blank_record = false unless column.association.klass.authorized_for?(:action => :create)

-%>
<h5><%= column.label -%> (<%= link_to_visibility_toggle(:default_visible => !column.collapsed) -%>)</h5>
<div <%= 'style="display: none;"' if column.collapsed -%>>
<%= hidden_field_tag "record[#{column.name}]" %>
<table cellpadding="0" cellspacing="0">
  <% @record = column.association.klass.new -%>
  <%= render :partial => 'form_association_header', :locals => {:parent_record => parent_record} %>

  <tbody id="<%= sub_form_list_id(:association => column.name) %>">
    <% associated.each_index do |index| %>
    <% @record = associated[index] -%>
    <% if @record.errors.count -%>
    <tr class="association-record-errors">
      <td colspan="<%= active_scaffold_config_for(@record.class).subform.columns.length + 1 %>">
        <%= error_messages_for :record %>
      </td>
    </tr>
    <% end %>
    <tr class="association-record <%= 'association-record-new' if @record.new_record? -%>">
      <% scope = column.plural_association? ? "[#{column.name}][#{@record.id || generate_temporary_id}]" : "[#{column.name}]" -%>
      <%= render :partial => 'form_association_record', :locals => {:scope => scope, :parent_record => parent_record} %>
    </tr>
    <% end -%>

    <% if show_blank_record -%>
    <% @record = column.association.klass.new -%>
    <tr class="association-record association-record-new locked">
      <% scope = column.plural_association? ? "[#{column.name}][#{generate_temporary_id}]" : "[#{column.name}]" -%>
      <%= render :partial => 'form_association_record', :locals => {:scope => scope, :parent_record => parent_record} %>
    </tr>
    <% end -%>
  </tbody>
</table>

<%= render :partial => 'form_association_footer', :locals => {:parent_record => parent_record, :column => column, :associated => associated} -%>
</div>
<% @record = parent_record -%><commit_msg>rolling back my change to allow the removal of the last association in a subform. i'm stumped. going to open an issue ticket.<commit_after><%
parent_record = @record
associated = column.singular_association? ? [parent_record.send(column.name)].compact : parent_record.send(column.name)
associated = associated.sort_by {|r| r.new_record? ? 99999999999 : r.id} unless column.association.options.has_key?(:order)

show_blank_record = (column.plural_association? or (column.singular_association? and associated.empty?))
show_blank_record = false if column.through_association?
show_blank_record = false unless column.association.klass.authorized_for?(:action => :create)

-%>
<h5><%= column.label -%> (<%= link_to_visibility_toggle(:default_visible => !column.collapsed) -%>)</h5>
<div <%= 'style="display: none;"' if column.collapsed -%>>
<table cellpadding="0" cellspacing="0">
  <% @record = column.association.klass.new -%>
  <%= render :partial => 'form_association_header', :locals => {:parent_record => parent_record} %>

  <tbody id="<%= sub_form_list_id(:association => column.name) %>">
    <% associated.each_index do |index| %>
    <% @record = associated[index] -%>
    <% if @record.errors.count -%>
    <tr class="association-record-errors">
      <td colspan="<%= active_scaffold_config_for(@record.class).subform.columns.length + 1 %>">
        <%= error_messages_for :record %>
      </td>
    </tr>
    <% end %>
    <tr class="association-record <%= 'association-record-new' if @record.new_record? -%>">
      <% scope = column.plural_association? ? "[#{column.name}][#{@record.id || generate_temporary_id}]" : "[#{column.name}]" -%>
      <%= render :partial => 'form_association_record', :locals => {:scope => scope, :parent_record => parent_record} %>
    </tr>
    <% end -%>

    <% if show_blank_record -%>
    <% @record = column.association.klass.new -%>
    <tr class="association-record association-record-new locked">
      <% scope = column.plural_association? ? "[#{column.name}][#{generate_temporary_id}]" : "[#{column.name}]" -%>
      <%= render :partial => 'form_association_record', :locals => {:scope => scope, :parent_record => parent_record} %>
    </tr>
    <% end -%>
  </tbody>
</table>
<%= render :partial => 'form_association_footer', :locals => {:parent_record => parent_record, :column => column, :associated => associated} -%>
</div>
<% @record = parent_record -%>
{'fraction_non_alphanumeric': 0.19028595458368378, 'fraction_numerical': 0.00672834314550042, 'mean_word_length': 4.703836930455635, 'pattern_counts': {'":': 0, '<': 84, '<?xml version=': 0, '>': 122, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7312766', 'n_tokens_mistral': 1665, 'n_tokens_neox': 1560, 'n_words': 284}