<commit_before>module Surveyable
  module SurveysHelper
    def link_to_remove_fields(name, form)
      form.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)", class: 'remove_link')
    end

    def link_to_add_fields(name, form, association)
      new_object = form.object.class.reflect_on_association(association).klass.new

      3.times { new_object.answers.build } if new_object.class.to_s == 'Surveyable::Question'

      fields = form.fields_for(association, new_object, child_index: "new_#{association}") do |builder|
        render(association.to_s.singularize + "_fields", form: builder)
      end

      link_to_function(name, "add_fields(this, \"#{association}\", \"#{escape_javascript(fields)}\")", class: 'button icon-plus')
    end
  end
end<commit_msg>Add button must load 4 answers, not 3.<commit_after>module Surveyable
  module SurveysHelper
    def link_to_remove_fields(name, form)
      form.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)", class: 'remove_link')
    end

    def link_to_add_fields(name, form, association)
      new_object = form.object.class.reflect_on_association(association).klass.new

      4.times { new_object.answers.build } if new_object.class.to_s == 'Surveyable::Question'

      fields = form.fields_for(association, new_object, child_index: "new_#{association}") do |builder|
        render(association.to_s.singularize + "_fields", form: builder)
      end

      link_to_function(name, "add_fields(this, \"#{association}\", \"#{escape_javascript(fields)}\")", class: 'button icon-plus')
    end
  end
end
{'fraction_non_alphanumeric': 0.1260137242669994, 'fraction_numerical': 0.002495321272613849, 'mean_word_length': 4.588850174216028, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '512960', 'n_tokens_mistral': 523, 'n_tokens_neox': 516, 'n_words': 98}