<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)

if column.show_blank_record
  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)
else
  show_blank_record = false
end

if show_blank_record
  if column.singular_association?
    associated << column.association.klass.new
  else
    associated.build
  end
end
-%>
<h5><%= column.label -%> (<%= link_to_visibility_toggle(:default_visible => !column.collapsed) -%>)</h5>
<div <%= 'style="display: none;"' if column.collapsed -%>>
<%= render :partial => subform_partial_for_column(column), :locals => {:column => column, :parent_record => parent_record, :associated => associated} %>
</div>
<% @record = parent_record -%><commit_msg>Fix show blank record for plural associations without order option<commit_after><%
parent_record = @record
associated = column.singular_association? ? [parent_record.send(column.name)].compact : parent_record.send(column.name).to_a
associated = associated.sort_by {|r| r.new_record? ? 99999999999 : r.id} unless column.association.options.has_key?(:order)

if column.show_blank_record
  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)
else
  show_blank_record = false
end

associated << column.association.klass.new if show_blank_record
-%>
<h5><%= column.label -%> (<%= link_to_visibility_toggle(:default_visible => !column.collapsed) -%>)</h5>
<div <%= 'style="display: none;"' if column.collapsed -%>>
<%= render :partial => subform_partial_for_column(column), :locals => {:column => column, :parent_record => parent_record, :associated => associated} %>
</div>
<% @record = parent_record -%>
{'fraction_non_alphanumeric': 0.14157706093189965, 'fraction_numerical': 0.011648745519713262, 'mean_word_length': 6.4186046511627906, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 37, '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': '820189', 'n_tokens_mistral': 747, 'n_tokens_neox': 696, 'n_words': 141}