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

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

Fix show blank record for plural associations without order option
Fix show blank record for plural associations without order option
